SEMblog

On my technical site amset.info I have an article on how to detect the operating system in a login script. The method that I use is to dump the results of ver out to a text file, then find the version number in those results. Here is a code snippet based on what is on that page, for detecting Windows XP. (http://www.amset.info/loginscripts/os-id.asp)

ver >"%userprofile%"\ver.txt

Rem now find the operating system and act accordingly

findstr 5.2 "%userprofile%"\ver.txt if errorlevel 1 goto XP

:notxp echo not XP

goto end

:xp echo XP

goto end

:end echo end

When Vista was released, I decided to update the page to include Vista as an example. I therefore added the following line:

findstr 6.0 "%userprofile%"\ver.txt if errorlevel 1 goto Vista

However this was based on theory, and wasn't something that I had time to test before I uploaded the new page.

Needing to use it for a client who has a couple of Vista machines and part of the login script wasn't required for Vista, I tried using my own code to skip that section. If failed to work correctly and I couldn't understand why it wouldn't skip the section I wanted, but worked for older versions of Windows.