Home > Batch Script, Windows > Batch – Common Variables & Shortcuts

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 \

  1. No comments yet.
  1. No trackbacks yet.