Find OS
Posted: 11 Mar 2013 17:19
Evening all,
I'm very new to writing batch files and need a bit of help. I've "borrowed" some code off the internet to find the OS and now I want to add a "goto" command in but I can't seem to get it to work. Where am I going wrong?
Original code:
I'm now trying to add in, after "pause", the "goto command of:
I'm sure it's simple but I have no idea what's wrong. I've tried every version of the goto command I can think of!
I'm very new to writing batch files and need a bit of help. I've "borrowed" some code off the internet to find the OS and now I want to add a "goto" command in but I can't seem to get it to work. Where am I going wrong?
Original code:
Code: Select all
::Identify OS
ver | find /i "version 6.2." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 8
ver | find /i "version 6.1." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 7
ver | find /i "version 6.0." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows Vista
ver | find /i "version 5.1." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows XP
ver | find /i "version 5.2." > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 2003
ver | find /i "Windows 2000" > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 2000
ver | find /i "Windows NT" > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows NT
ver | find /i ">Windows ME" > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows ME
ver | find /i "Windows 98" > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 98
ver | find /i "Windows 95" > nul
if %errorlevel%==0 set $VERSIONWINDOWS=Windows 95
::Identify bit
IF NOT EXIST "%SYSTEMDRIVE%\Program Files (x86)" set $VERSIONBIT=32 bit
IF EXIST "%SYSTEMDRIVE%\Program Files (x86)" set $VERSIONBIT=64 bit
::Display result
echo %$VERSIONWINDOWS% %$VERSIONBIT%
echo.
pause
I'm now trying to add in, after "pause", the "goto command of:
Code: Select all
if %$VERSIONWINDOWS%==Windows 7 goto :ver_7
:ver_8
echo Windows 8
:ver_7
echo Windows 7
I'm sure it's simple but I have no idea what's wrong. I've tried every version of the goto command I can think of!