- Scan Windows system and catch log:
sfc /scannow
findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log >C:\Users\<username>\Desktop\sfcdetails.txt
- System/Builtin variables in
cmd
: (batch script)
- Builtin variables:
VARIABLE | WINDOWS 10 |
---|---|
%ALLUSERSPROFILE% | C:\ProgramData |
%APPDATA% | C:\Users\{username}\AppData\Roaming |
%COMMONPROGRAMFILES% | C:\Program Files\Common Files |
%COMMONPROGRAMFILES(x86)% | C:\Program Files (x86)\Common Files |
%CommonProgramW6432% | C:\Program Files\Common Files |
%COMSPEC% | C:\Windows\System32\cmd.exe |
%HOMEDRIVE% | C:\ |
%HOMEPATH% | C:\Users\{username} |
%LOCALAPPDATA% | C:\Users\{username}\AppData\Local |
%LOGONSERVER% | \\{domain_logon_server} |
%PATH% | C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem |
%PathExt% | .com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh;.msc |
%PROGRAMDATA% | C:\ProgramData |
%PROGRAMFILES% | C:\Program Files |
%ProgramW6432% | C:\Program Files |
%PROGRAMFILES(X86)% | C:\Program Files (x86) |
%PROMPT% | $P$G |
%SystemDrive% | C: |
%SystemRoot% | C:\Windows |
%TEMP% | C:\Users\{username}\AppData\Local\Temp |
%TMP% | C:\Users\{username}\AppData\Local\Temp |
%USERDOMAIN% | Userdomain associated with current user. |
%USERDOMAIN_ROAMINGPROFILE% | Userdomain associated with roaming profile. |
%USERNAME% | {username} |
%USERPROFILE% | C:\Users\{username} |
%WINDIR% | C:\Windows |
%PUBLIC% | C:\Users\Public |
%PSModulePath% | %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\ |
%OneDrive% | C:\Users\{username}\OneDrive |
%DriverData% | C:\Windows\System32\Drivers\DriverData |
%CD% | Outputs current directory path. (Command Prompt.) |
%CMDCMDLINE% | Outputs command line used to launch current Command Prompt session. (Command Prompt.) |
%CMDEXTVERSION% | Outputs the number of current command processor extensions. (Command Prompt.) |
%COMPUTERNAME% | Outputs the system name. |
%DATE% | Outputs current date. (Command Prompt.) |
%TIME% | Outputs time. (Command Prompt.) |
%ERRORLEVEL% | Outputs the number of defining exit status of previous command. (Command Prompt.) |
%PROCESSOR_IDENTIFIER% | Outputs processor identifier. |
%PROCESSOR_LEVEL% | Outputs processor level. |
%PROCESSOR_REVISION% | Outputs processor revision. |
%NUMBER_OF_PROCESSORS% | Outputs the number of physical and virtual cores. |
%RANDOM% | Outputs random number from 0 through 32767. |
%OS% | Windows_NT |
$ echo %systemroot%
C:\WINDOWS
$ echo %userprofile%
C:\Users\<username>
$ echo %windir%
C:\WINDOWS
$ echo %appdata%
C:\Users\<username>\AppData\Roaming
-
List all environments variable:
-
List all environment variables (cmd.exe):
set setx [variable_name] "[variable_value]"
-
Show value of a specific variable (powershell.exe / pwsh.exe):
echo $Env:[variable_name]
-
Manage using Registry Editor:
reg query HKEY_CURRENT_USER\Environment reg query HKEY_CURRENT_USER\Environment /v [variable_name] reg delete HKEY_CURRENT_USER\Environment /v [variable_name] /f reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v [variable_name] reg delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v [variable_name] /f reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "ProxyServer" /t REG_SZ /d "http://procycorp.bac:80" /f reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "ProxyEnable" /t REG_DWORD /d "0" /f
-
bitsadmin
: BITS administration utility:@REM Admin privileges required to become all executable commands: bitsadmin /util /setieproxy localsystem MANUAL_PROXY procycorp.bac:80 "localhost" bitsadmin /util /getieproxy localsystem
-
- Multi-line comments in Bash script: cyberciti.biz
- Using
HERE Document
:
<<COMMENT
Your comment1
Your comment2
Your comment3
COMMENT
- Using
comment block
: putEOF
here to avoid command execution and phrasing
: <<'EOF'
CODE block starts
CODE block ends
EOF
-
Using multi-line shell script comments:
:
(colon) := [arguments] No effect; the command does nothing beyond expanding arguments and performing any specified redirections. A zero exit code is returned.
: '
Your comment1
Your comment2
Your comment3
'