Useful Windows Batch File Snippets

REM   This is a comment
::    This is too, but only newer CMD versions
echo hello &:: This is a line comment, because & seperates commands

REM   Set and display variables:
set a=5
echo %a%
set a=5 & echo %a% &:: Not equivalent! Not evaluated left to right!

REM   Show available commands:
help

REM   Show help on specific commands (both display the same): 
help dir
dir /?

REM   Redirect command output to file:
dir > test.txt

REM   Append command output to file:
dir >> test.txt

REM   Show File contents:
type test.txt

REM   Redirect command output to another command:
type test.txt | more