how can i tell if a OS is WinXP WITH SP2?

  • Thread starter Thread starter Gill Bates
  • Start date Start date
G

Gill Bates

how can i tell if a OS is WinXP WITH SP2?

Using ver, find and simples tools

now, i'm using:

ver | find "XP"
if errorlevel 1 goto WRONGOS


But i would like to certify the SP level
 
Hello, Gill:
On Fri, 26 Nov 2004 17:35:39 -0200: you wrote...

GB>
GB> Using ver, find and simples tools
GB>
GB> now, i'm using:
GB>
ver |> find "XP"
GB> if errorlevel 1 goto WRONGOS
GB>

After determinig that it is XP the I believe these checks will work:
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CSDVersion
| find "Service Pack 2"
echo %ERRORLEVEL%
reg query "HKLM\SYSTEM\CurrentControlSet\Control\Windows" /v CSDVersion |
find "0x200"
echo %ERRORLEVEL%

Regards, Paul R. Sadowski [MVP].
 
When executed within a shell script, this will set an environment
variable to the service pack major version -

for /f %%v in ('wmic os get servicepackmajorversion /value') do set %%v

.... output needs a little tidying up but I'm sure you get the idea.
 
When executed within a shell script, this will set an environment
variable to the service pack major version -

for /f %%v in ('wmic os get servicepackmajorversion /value') do set %%v

... output needs a little tidying up but I'm sure you get the idea.

The following is one line.

for /f "tokens=2 delims==" %%v in (
'wmic os get servicepackmajorversion /value ^| find "ServicePack"'
) do if %%v LSS 2 echo Too Low

WMIC, Reg, SC and even Regini make managing XP and 2003 much easier
than NT and 2000 boxes, at least for me it does.

Clay Calvert
(e-mail address removed)
Replace "W" with "L"
 
how can i tell if a OS is WinXP WITH SP2?

Using ver, find and simples tools

now, i'm using:

ver | find "XP"
if errorlevel 1 goto WRONGOS
But i would like to certify the SP level

Here are a few self-documenting variations
using the FREE Advanced Command Library and
Mount/\Commands. All of them work CONSISTENTLY
on any NT-based OS, out of the box.

Use the code that makes your script the
most readable. For example:

CALL ntlib.cmd /q :SI
%.ifNotXP% GOTO :Wrong_OS
IF %#ServicePack% LSS 2 GOTO :Wrong_ServicePack

*******

CALL ntlib.cmd /Quiet :System_Info
%.ifXP% (
IF %#ServicePack% EQU 2 (
ECHO:XP with Service Pack 2
)
)

*******

CALL ntlib.cmd /Q :SI
%.ifXP% (
IF NOT %#ServicePack% EQU 2 (
ECHO:SP2 not found
)
) ELSE (
ECHO:Not Windows XP
)

*******

CALL ntlib.cmd /q :SI
%.ifNotXP% (
ECHO:Not XP
) ELSE (
IF NOT %#ServicePack% EQU 2 (
ECHO:XP with Service Pack %#ServicePack%
) ELSE (
ECHO:XP with SP2
)
)

*******

For more information and examples, see
(http://TheSystemGuard.com/MtCmds/IfCondition/ifXP.htm)
(http://TheSystemGuard.com/NTCmdLib/Procedures/SI.htm)
(http://thesystemguard.com/NTCmdLib/GlobalSwitches)
(http://TheSystemGuard.com/NTCmdLib/Constants)

For cross-platform command references, see
(http://TheSystemGuard.com/TheGuardBook/CCS-Int/CALL.htm)
(http://TheSystemGuard.com/TheGuardBook/CCS-Int/ECHO.htm)
(http://TheSystemGuard.com/TheGuardBook/CCS-Int/GOTO.htm)
(http://TheSystemGuard.com/TheGuardBook/CCS-Int/IF.htm)

*******

ifXP, ifNotXP and over 150 other commands are included in
the FREE Advanced NT/2K/XP/K3 Command Library (ntlib.cmd).

Request your copy at (http://ntlib.com).

*******

What is a .Mount/\Command?

An optimized section of cross-platform shell scripting
code that is stored in an environment variable under a
"sounds like what it does" name. Only builtin commands
common to all four platforms (NT/2K/XP/K3) are used.
There is NO BINARY CODE, only scripting code.

Since the code is "cached" in the local environment,
performance is similar to native commands like FOR,
DIR, etc. One call to the library at the beginning
of your script preloads all 150+ "Mounted Commands".

-tsg

/-----------------+---------------+----------------------\
| COMPATIBILITY | CLARITY | SPEED |
| Write code ONCE | Make it clear | THEN...Make it fast! |
\-----------------+---------------+----------------------/
400+ command-line resources using ONLY native NT commands!
(http://TheSystemGuard.com/default.asp#MasterCommandList)
 
Back
Top