Batch or VB script to determine what version of Windows (XP or 7) our machines are?

hi guys

We are trying to deploy software, either 32 bit or 64 bit, depending on the version of Windows. However, there are around 150 PC's and we just wanted to know whether we have Windows XP or Windows7 on these PC's.

Is there a way I can run a batch file or VB script on our Domain Controller to obtain this information? I can see that in AD, if I right click on the computer properties and select the Operating System tab that this information is available, but is there a way we could extract that information with a script and associate that OS to the computer name?

The controller is a Windows 2003 version.

Thanks for helping
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


pls try
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set oss = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

For Each os In oss
    Debug.Print os.Caption & vbCrLf & "Version: " & os.Version
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
YashyAuthor Commented:
Hey Rgonzo,

Thanks so much for sending me this. I tried this by making it a VBS script and ran it. Sadly it errored.
replace Debug.Print with WScript.Echo
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

YashyAuthor Commented:
Same thing.

I get an error saying 'Windows Script Host'

Line: 7
Char: 1
Error: Expected Statement
Code 800A0400
Source; Microsoft VBscript compilation error.

Is this supposed to output a text file or export into a specific location?
delete end sub
YashyAuthor Commented:
this only gave me the version of our actual Domain controller.

That's my fault, I  went on writing about the domain controller. Is there a way to run a similar file, but to obtain a list of all the PC's in an organisational unit in AD, so that all of the 150 PC's we have, their information can be extracted to tell us which version of windows each runs? Apologies for the confusion, and thanks for helping.
YashyAuthor Commented:
I will close this and give you points and do another post for this. As it's unfair the way it was posted for you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.