Is there any way I can manipulate a batch file to determine if a machine is running Windows XP or Windows 2000? As far as I can tell, both OS's use the same system variable of Windows_NT. Any help would be appreciated.
If this batch file is going to be run in a controlled environment, IE: your own network, then why don't you set a new environment variable on your machines? Perhaps something like winver=Win2K and winver=XP.
I could do that, I just wondered if there was an easier way to go about it that I was not thinking of. I could go through and change all the WinXP machine's variables without too much hassle I suppose.
There is inexpensive software available that will allow you to scan pc's and send you back a report as to not only what os, but the software and such. Give me a couple of days and I'll let you know the name. (It's at my old job, and I can't get at it till Monday.) You can put the batch file from this software in the scripts file, and when the user logs on, it scans the pc and sends a report to a file you designate. Good stuff, but I haven't used it since leaving old job.
Glen A. Johnson
Johnson Computer Consulting
MCP W2K
glen@johnsoncomputers.us
Run a fairly standard .vbs or call it from a .bat with the script host wscript.exe with the .vbs file as the parameter.
'---.vbs---
Option Explicit
Dim strComputer, objWMIService, colOS, objOS
'Set your computername (remote or local "."
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2"
Set colOS = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem"
For Each objOS in colOS
Wscript.Echo "Caption/Name : " & objOS.Caption & vbcrlf & _
"Version : " & objOS.Version
Next
'---.vbs---
(you specify the strComputer which is isolated here as a constant.)
Some of the captions & versions I can reach more easily look like:
1.1 win98
Caption : Microsoft Windows
Version : 4.10.1998
1.2 win98SE
Caption : Microsoft Windows
Version : 4.10.2222A
2 winME
Caption : Microsoft Windows
Version : 4.90.3000
3 win2000
Caption : Microsoft Windows 2000 Professional
Version : 5.0.2195
Caption : Microsoft Windows 2000 Server
Version : 5.0.2195
Caption : Microsoft Windows 2000 Advanced Server
Version : 5.0.2195
4 winXP will show Version 5.1.2600 Home or Professional.
I have figured out a very easy way to go about solving my problem by using the "ver" command in the batch file. Here is how it works.
@echo off
ver |find "XP">nul
if errorlevel 1 goto win2000
REM perform WinXP related functions here
goto end
:win2000
ver |find "2000">nul
if errorlevel 1 goto end
REM perform Win2K functions here
goto end
:end
end
That is it...........not sure why I never thought of it sooner, but it works really slick. And now I don't have to change the system variables on any machine.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.