Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft.
Index
Shell
Redirect stdout
to a file.
command > out
Redirect stderr
to a file.
command 2> error
Redirect stdout
to a file and stderr
to stdout
.
command > out 2> &1
Redirect to NUL
.
command > nul
command 2> nul
Command | Description |
---|---|
cd | Change directory. |
cls clear |
Clear the console. |
dir ls |
List files and directories. |
dir env: ls env: |
List the environment variables. |
set | Set an environment variable. |
scp -r file user@ip:path | Secure copy files or directories between 2 computers. |
systeminfo | Displays detailed configuration information about the computer and operating system. |
$env:name="value" | Set an environment variable. |
PowerShell script ps1
cannot be loaded because running scripts is disabled on this system.
- Run PowerShell as administrator by clicking "Run as Administrator".
- Get the current execution policy with the command
Get-ExecutionPolicy
, the value would beRestricted
. - Set the execution policy with the command
Set-ExecutionPolicy RemoteSigned
and type "Y".
PowerShell redirect stdin
and stdout
.
Get-Content input.txt | program.exe > output.txt
Start-Process "program.exe" -RedirectStandardInput "input.txt" -RedirectStandardOutput "output.txt" -NoNewWindow -Wait
File System
Hosts file maps human-friendly hostnames to numerical Internet Protocol (IP) addresses.
C:\Windows\System32\Drivers\etc\hosts