Batch – Common Variables & Shortcuts
:: Keep variables local
SETLOCAL (Define at beginning of script)
ENDLOCAL (Release variables at end of script)
:: Set Date Variable
set CurrentDATE=%date:~4,2%-%date:~7,2%-%date:~10,4%
set CurrentTime=%time:~0,2%.%time:~3,2%
Output: 09-15-08
:: Current Host Name
set name=%hostname%
::Current working directory
%CD% – Gives current working directory with no preceding \
%~dp0 – Gets current working directory with a preceding \
Categories: Batch Script, Windows
batch, common variables, current working directory, layout