Windows Batch Script
Jump to navigation
Jump to search
Windows Batch Script is a crucial instrument for setting up PKC on Windows 10 platform.
Useful Websites
- Batch Script Tutorial on Tutorial Point
- Batch File to Create Formatted Date and Time
- Batch File Programming
Useful Hints
The following special expressions or characters may be useful in understanding Batch Script:
SET /A
SET varibale_name=variable_value :: for assigning numeric value SET /A variable_name=nameric_value
‘/A’ is used for assigning numeric values. Uninitialized variables are empty strings in batch files.
FOR /L
FOR /L %%var_name IN (Lowerlimit, Increment, Upperlimit) Do some_code
- ‘/L’ signifies that for loop is used for iterating through a range of integer values.
- Lower limit is the value from which loop will start until it reaches the Upper limit and the increment is the value with which lower limit will be increased during each iteration
Formatting Date and Time
@echo off set yy=%date:~-4% set mm=%date:~-7,2% set dd=%date:~-10,2% set MYDATE=%yy%%mm%%dd%
For using delimiters, try the following:
for /f “tokens=2-4 delims=/ ” %%g in (‘date /t’) do ( set mm=%%h set dd=%%g set yy=%%i ) set MYDATE=%yy%%mm%%dd%