The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,513 other followers

Archive for February 8th, 2012

Batch file to detect Windows version number

Posted by jpluimers on 2012/02/08

Most Batch files for detecting Windows versions try to parse the either the [WayBack] output fromVER  or the [WayBackoutput from SYSTEMINFO [WayBack], but forget that there many Windows installations are not English. Some even use WMIC, but [WayBackWMIC is only available for administrators and not available some flavours like XP Home.

Languages issues are always important to watch for. The Dutch Windows XP returns Microsoft Windows XP [versie 5.1.2600] which is just one word different from the English Microsoft Windows XP [Version 5.1.2600]. Other languages may differ even more.

This batch file tries to circumvent the language differences, uses VER and works at least with Dutch and English Windows versions of XP and 7, most likely with many other languages and versions as well.

On a Windows XP SP3 machine, it lists WindowsVersion=5.1.2600 and on a Windows 7 SP1 machine it lists WindowsVersion=6.1.7601.

One possible addition would be to [WayBack] detect x64 or x86.

The detection assumes that VER will emit the version in [angle] brackets, and uses two batch file for loops to get the text in between them using the [WayBacktokens and delims for loop parameters in the first for loop right behind the begin label and the second for loop right after the parse1 label.

Then it splits the remaining text using spaces at the parse2 label, and takes the right most portion using the [WayBackshift command at the parse3 label.

Many thanks to [WayBackRob van der Woude for a lot of interesting batch file documentation. Read the rest of this entry »

Posted in Batch-Files, Power User, Scripting, Software Development, Windows, Windows 7, Windows XP | Leave a Comment »

 
%d bloggers like this: