[CMD] Как мне получить весь этот пакетный файл для вывода в блокнот?

Malnutrition

Студенты 1 курс
Сообщения
97
Реакции
15
Код:
@echo off
WMIC /Namespace:\\root\default Path SystemRestore Call CreateRestorePoint "BatchRestorePoint", 100, 10
fsutil resource setautoreset true c:\&fsutil usn deletejournal /d /n c:
powercfg.exe /setactive 381b4222-f694-41f0-9685-ff5bb260df2e
powercfg -hibernate off
netsh advfirewall reset
netsh advfirewall set allprofiles state On
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ("76.76.19.19", "8.8.4.4")
%WINDIR%\SYSTEM32\lodctr.exe /R
%WINDIR%\SysWOW64\lodctr.exe /R
C:\Windows\SYSTEM32\lodctr.exe /R
C:\Windows\SysWOW64\lodctr.exe /R
Dism.exe /online /Cleanup-Image /StartComponentCleanup
pause
DISM.exe /Online /Cleanup-image /Restorehealth
pause
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
pause
del /s /q C:\Windows\SoftwareDistribution\download\*.*
del /s /q "%userprofile%\AppData\Local\Google\Chrome\User Data\Default\Cache\*.*"
del /s /q "%userprofile%\AppData\Local\Opera Software\Opera Stable\Cache\Cache_Data\*.*"
del /s /q "%userprofile%\AppData\Local\temp\*.*"
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
ipconfig /flushdns
sc stop sysmain
sc config sysmain start= disabled
sc stop DiagTrack
sc config DiagTrack start= disabled
sc stop dmwappushservice
sc config dmwappushservice start= disabled
sc stop WSearch
sc config WSearch start= disabled
sc stop lfsvc
sc config lfsvc start= disabled
del /s /q %ProgramData%\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\parameters /v DisabledComponents /t REG_DWORD /d 0xFFFFFFFF
reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 0xFFFFFFFF
sfc /scannow
pause
shutdown -r
Exit /B
 

Malnutrition

Студенты 1 курс
Сообщения
97
Реакции
15
I'm asking what command should I use so that I can get the batch file to output everything it does into a notepad upon completion.

I know if you run this, ipconfig /all >"%userprofile%\desktop\ipconfig.txt" it will give me a notepad named ipconfig.txt onto my desktop. But that is just one command, how to get the output of multiple commands?

So how to get the everything that the batch file does onto a notepad? Would I need to add >"%userprofile%\desktop\batchresult.txt" after each command?
 

Dragokas

Very kind Developer
Команда форума
Супер-Модератор
Разработчик
Клуб переводчиков
Сообщения
6,716
Реакции
6,208
There are several ways to do so.

1) You have to use >> syntax next to each individual command like so:
Код:
command >> 1.log 2>&1
>> or 1>> redirects stream #1 (StdOut) to logfile in "write append" mode.
2>> redirects stream #2 (StdErr). Or 2>&1 (if steam 1 specified) will concatenate stream #2 to stream #1.

Note1: you can use > 1.log 2>&1 (single >) next to the very first command to force "overwrite" mode to erase file on first call, like so:
Код:
set logfile=1.log
first command > "%logfile%" 2>&1
second command >> "%logfile%" 2>&1
third command >> "%logfile%" 2>&1

Note2: to prevent including a leading whitespace in the logfile (for cases like "echo") you can specify redirection directive at the left side, e.g.:
Код:
> "%logfile%" 2>&1 first command

1a) You could use "commands block union" way, like so:
Код:
(
second command
third command
) >> "%logfile%" 2>&1
However, I would not suggest to do so, because it is suffer from console buffer limits and also can harm to correct command execution (for some commands, e.g. icacls).

2) If you have an external launcher of your batch file, you can easily redirect all output using same syntax outside, e.g.:
Код:
cmd.exe /c callee.bat >1.log 2>&1

3) Undocumented way (found by myself):

Place this line at the top of your batch-file:
Код:
echo. 1>&3 2>&4 3>>"1.txt" 4>&3

Note1: This can also include the executed command itself in the log if you use "echo on" (or omit "echo off").
Note2: You cannot see any output in the console even those produced by "pause", however, all those lines redirected to file and StdIn works as usual (you can skip "pause" by pressing any key).
Note3: Using this way, you cannot select which command to redirect and which not. AFAIK, it's not possible to disable such logging in the middle-time, at least I don't know the way.
 
Последнее редактирование:

Malnutrition

Студенты 1 курс
Сообщения
97
Реакции
15
Спасибо за подробный ответ. Я играю с некоторыми предложениями, я дам вам знать результат. Не могли бы вы прислать ссылку, где вы получили эту информацию, пожалуйста. Я хотел бы учиться сам, а не просто получать информацию от кого-то с одной ложки.
 

Dragokas

Very kind Developer
Команда форума
Супер-Модератор
Разработчик
Клуб переводчиков
Сообщения
6,716
Реакции
6,208
Сверху Снизу