Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File 1

Status
Not open for further replies.

bkesting

IS-IT--Management
Apr 14, 2003
180
0
0
US
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.

Thanks.
 
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

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884

"Once the game is over, the king and the pawn return to the same box."
 
Hello bkesting,

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.

regards - tsuji
 
i will give it a shot, thanks.

Brian
 
I've used this in the past, and it's great. You can load it in the scripts, and it will run when the user logs on.

Check it out.

Glen A. Johnson
Johnson Computer Consulting
MCP W2K
glen@johnsoncomputers.us

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884

"Once the game is over, the king and the pawn return to the same box."
 
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.
 
Here, give yourself a star, (If D&D will allow it.) Never mind, here's one from me. Nice going.
[2thumbsup]

Glen A. Johnson
Johnson Computer Consulting
MCP W2K
glen@nellsgiftbox.com

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884

"Once the game is over, the king and the pawn return to the same box."
 
You go do somthing like this

REM (Operating System Version Check)
Ver | find "2000" >Nul
if not errorlevel 1 Goto 2000

Ver | find "XP" >Nul
if not errorlevel 1 goto XP
 
I came up with this batch file earlier today as a one line detection for myself. By using a .cmd file then 9x won't run it.

for /f "tokens=3" %%h in ('ver ^| find "Microsoft"') do goto %%h
echo "Neither XP nor 2000"
goto end

:2000
echo W2K

goto end

:xp
echo XP

:end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top