T
Tim Snider
I have created a batch file to set a variable for different OS's. (Other
than the Standard Ones)
REM Begin~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@echo off
cls
echo Stand by inspecting your system.
echo.
echo OS check
:check1
for /f "usebackq tokens=1,2,3" %%i in (`ver`) do set OSVer=%%i %%j %%k
set
Pause
echo This is your Operating System: %OSVer%
pause
echo.
IF % %OSVer%%==Microsoft Windows XP goto Win2k
goto WrongOS
:Win2k
echo Your system is %%OSVer%%
pause
:WrongOS
echo OS not supported.
pause
exit
REM End~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now the "For" line creates a string like Microsoft Windows 2000 and sets a
variable called OSVer.
When I run %%OSVer%% from within the batch file it returns "Microsoft
Windows 2000" string ok.
Problem lies in the IF statement
Running the batch file it ends the batch file and I can't see what the error
is.
Then I tried to trouble shoot this from the command prompt,
I type the for statement to set the variable.
for /f "usebackq tokens=1,2,3" %i in (`ver`) do set OSVer=%i %j %k
I type the "Set" command and view the variables and OSVer is set correctly.
I then type the IF statement as shown below just to test it out
IF %OSVer%==Microsoft Windows 2000 echo OK
I then get an error saying that "Windows was unexpected at this time"
Can anyone tell me what is wrong with this statement? And why I am getting
this error?
than the Standard Ones)
REM Begin~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@echo off
cls
echo Stand by inspecting your system.
echo.
echo OS check
:check1
for /f "usebackq tokens=1,2,3" %%i in (`ver`) do set OSVer=%%i %%j %%k
set
Pause
echo This is your Operating System: %OSVer%
pause
echo.
IF % %OSVer%%==Microsoft Windows XP goto Win2k
goto WrongOS
:Win2k
echo Your system is %%OSVer%%
pause
:WrongOS
echo OS not supported.
pause
exit
REM End~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now the "For" line creates a string like Microsoft Windows 2000 and sets a
variable called OSVer.
When I run %%OSVer%% from within the batch file it returns "Microsoft
Windows 2000" string ok.
Problem lies in the IF statement
Running the batch file it ends the batch file and I can't see what the error
is.
Then I tried to trouble shoot this from the command prompt,
I type the for statement to set the variable.
for /f "usebackq tokens=1,2,3" %i in (`ver`) do set OSVer=%i %j %k
I type the "Set" command and view the variables and OSVer is set correctly.
I then type the IF statement as shown below just to test it out
IF %OSVer%==Microsoft Windows 2000 echo OK
I then get an error saying that "Windows was unexpected at this time"
Can anyone tell me what is wrong with this statement? And why I am getting
this error?