| 1. |
Solve : Determining Win Version (and keeping it simple)? |
|
Answer» Hi, What I would really like to do instead of generating a text description of the OS, is parse out the actual version string and get a number. You only get integer variables in batch. Anyhow the version numbers have more than one dot. The VER command... Windows 2000 Code: [Select]Microsoft Windows 2000 [Version 5.00.2195] Windows XP Code: [Select]Microsoft Windows XP [Version 5.1.2600] Windows 7 Code: [Select]Microsoft Windows [Version 6.1.7600] Code: [Select]echo off for /f "tokens=1,2,3 delims=[]" %%V in ('ver') do set versionstring=%%W for /f "tokens=1,2 delims= " %%A in ("%versionstring%") do set versionnumber=%%B for /f "delims=." %%M in ("%versionnumber%") do set majorversionnumber=%%M echo version string = %versionstring% echo full version number = %versionnumber% echo major version number = %majorversionnumber% REM you have EQU NEQ LEQ GEQ LSS GTR comparison operators REM Type IF /? at the prompt to see documentation if %majorversionnumber% LSS 6 ( echo Version number smaller than 6 ) else ( echo Version number greater than or equal to 6 ) Code: [Select]version string = Version 5.1.2600 full version number = 5.1.2600 major version number = 5 Version number less than 6 see here! http://windowsteamblog.com/blogs/developers/archive/2009/08/05/version-checking-just-don-t-do-it.aspxThanks for both posts Salmon. The only incompatibility that I am trying to avoid is related to pushing some shortcuts into the All Users STARTUP menu. So yeah. It is probably wiser for me to just look for the Win7 folder. If it exists, use it. Otherwise assume WinXP. Granted, this is very weak. But this is for a highly controlled environment where it should only be one of these two OSes. And, the same folders were used from Win2K through XP, and Vista through Win7. So it should work anyway if someone is out of OS spec. |
|