Jump to content

Check for OS Version in a script


Recommended Posts


  • 9 months later...

Hi Yzöwl,

I have been using your code successfully for months now:

for /f "delims=" %%? in ('net config work^|findstr/i "\<soft"') do call :OSis %%?

if %WinOS% == Vista goto :Vista
if %WinOS% == XP goto :XP

:OSis
echo/%*|find "2000">nul 2>&1&&(set "WinOS=XP"&goto :eof)
echo/%*|find "2002">nul 2>&1&&(set "WinOS=XP"&goto :eof)
echo/%*|find "2003">nul 2>&1&&(set "WinOS=XP"&goto :eof)
echo/%*|find "Vista">nul 2>&1&&(set "WinOS=Vista"&goto :eof)
echo/%*|find "2008">nul 2>&1&&(set "WinOS=Vista"&goto :eof)

Thanks again for it ! :-)

However, recently I am having a problem with this code on WinXP SP3 during runonceex. Seemingly out of nowhere the cmd stops right after this command:

for /f "delims=" %%? in ('net config work^|findstr/i "\<soft"') do call :OSis %%?

This does not happen on all the scripts where this code is present, just one. The strange thing is, if I press the ENTER key, it continues to run normally, no error appears, nothing. But it just stops there forever if noone presses a key.

Do you maybe have an explanation for it or a way around it ?

Thanks in advance,

Alex

Edited by midiboy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...