I have written using FOR statements that it will not need you to output everything to a text file first. This is significant if you are functioning in areas where you might not have mark access. I have also observe that sometimes you want to get rid of spaces like from the Date /T or Ver commands which in turn impressive like "Tue 06/20/2009" or "Microsoft Windows Version [6.0.6001]" into another variables.
Code:
@ECHO OFF
:; Clear the screen and turn echo off (above) to keep it clean
CLS
:; Clear any previous variables set
SET To=
SET DM=
SET MD=
SET Y=
SET Var1=
SET WinVe=
SET WinMa=
SET WinMi=
SET WinBu=
SET WD=
SET DOW=
:; Get Value from 'VER' command output
FOR /F "tokens=*" %%i in ('VER') do SET WinVe=%%i
FOR /F "tokens=1-3 delims=]-" %%A IN ("%WinVe%" ) DO (
SET Var1=%%A
)
:; Get version number only so drop off Microsoft Windows Version
FOR /F "tokens=1-9 delims=n" %%A IN ("%Var1%" ) DO (
SET WinVe=%%C
echo %WinVe%
)
:; Separate version numbers
FOR /F "tokens=1-8 delims=.-" %%A IN ("%WinVe%" ) DO (
SET WinMa=%%A
SET WinMi=%%B
SET WinBu=%%C
)
:; Fix the extra space left over in the Major
FOR /F "tokens=1 delims= " %%A IN ("%WinMa%" ) DO (
SET WinMa=%%A
)
:; Display Results
ECHO WinVe = %WinVe%
ECHO WinMa = %WinMa%
ECHO WinMi = %WinMi%
ECHO WinBu = %WinBu%
:; Pause for a moment
Pause
:; Get the output from the "Date /T"
FOR /F "tokens=*" %%i in ('DATE /T') do SET To=%%i
FOR /F "tokens=1-3 delims=/-" %%A IN ("%To%" ) DO (
SET DM=%%A
SET MD=%%B
SET Yr=%%C
)
:; Separate the Day from Month like "Tue 06" to "Tue"
FOR /F "tokens=1 delims= " %%A IN ("%DM%" ) DO (
SET DOW=%%A
)
:; Separate the Day from Month like "Tue 06" to "06"
FOR /F "tokens=2 delims= " %%A IN ("%DM%" ) DO (
SET Month=%%A
)
:; Now show the date output using your variables
ECHO Month = %Month%
ECHO DOW = %DOW%
ECHO Date = %DOW% %Month%/%MD%/%Y%
Bookmarks