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)