Wednesday, November 18, 2009

Detect/identify Windows version in batch commands (e.g. login scripts)

I updated the code below further on 11-04-09 to fix a couple bugs and add the %bits% variable.


I have since uploaded the code to Scribd.com and embedded it below.  Editing/posting code on Blogger stinks.  I think this should work out better.

It's often very useful (e.g. login scripts and such) to detect the version of the current operating system.  I originally started with some code from elsewhere (http://www.amset.info/loginscripts/os-id.asp), but I've enhanced it a lot over time.

Below is my latest version of this code.

This code also detects 32-bit vs. 64-bit, and if a system is running Server Core on Server 2008 or Server 2008 R2.

The %opsys% environmental variable is set to the current operating system (win9x, win2k, winxp, win2003, win2008, win2008R2, vista, win7).

The %pf% variable is set to the proper Program Files directory (generally c:\program files on 32-bit, c:\program files(x86) on 64-bit) for most software installs and/or checks.

The %servercore% variable is set to either "false" (it isn't a Server Core system) or "true" (it is a Server Core system).


The %bits% variable is set to either 32 (if a 32-bit system) or 64 (if a 64-bit system).


Os Detection Routines height="500" width="450" > value="http://d1.scribdassets.com/ScribdViewer.swf?document_id=22729575&access_key=key-vznqpa9tbk9ekd8hj9c&page=1&version=1&viewMode=book">            


No comments:

Post a Comment