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 \

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s