Solved

Identify Service Pack Via Command Line

Posted on 2009-05-03
14
2,908 Views
Last Modified: 2012-05-06
I am creating a boot cd and need to identify the service pack of the O/S installed.
I am primarily aiming at XP but if there is also a way for Vista that would be great.

Thanks
0
Comment
Question by:Moncapitaan
  • 5
  • 3
  • 3
  • +1
14 Comments
 
LVL 10

Accepted Solution

by:
cdebel earned 74 total points
ID: 24289878
I don't know if it inform for Service pack, but usually to identify the version of windows the command is "VER".  It should return something like Microsoft Windows XP [Version 5.1.2600]

To get the SP with some VBScript... here's the code:

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _

("SELECT * FROM Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems

Wscript.Echo objOperatingSystem.ServicePackMajorVersion _

& "." & objOperatingSystem.ServicePackMinorVersion

Next

Open in new window

0
 
LVL 10

Expert Comment

by:cdebel
ID: 24289881
I'm sure that you could create an environment variable to store the SP number.
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
ID: 24290085
PsInfo from SysInternals is able to ask remote for those infos, e.g. does
psinfo \\mycomputer | findstr /L /c:"Kernel" /c:"Service"
result in
Kernel version:            Microsoft Windows XP, Multiprocessor Free
Service pack:              3
Kernel build number:       2600
You could also use Registry: HKLM\Software\Microsoft\Windows NT\CurrentVersion\ with values BuildLab or BuildLabEx (comprehensive version string), or CSDBuildNumber or CSDVersion together with ProductName.
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 24290096
Thanks for the replies.

Questions:

1. Can I run VB script from a boot CD (booting to a command prompt in DOS (NTFS))
2. Can I inclide PsInfo on a boot CD I will distribute for free?
3. The CSD version sounds ok but how would I query the reg from boot cd?

Thanks
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
ID: 24290126
1. Don't think so
2. no, distribution is prohibited by Microsoft, even if for free (AFAIK)
3. You need access to reg utility (build-in with XP and later, else Resource Kit / Support Tools): reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" | findstr "CSD ProductName"
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 24290155
reg utility? would this work from DOS?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 213 total points
ID: 24290183
Depends on the "DOS" you use ... But it might be easier to use a tool to read the file version of some kernel files ...
"DOS" might not bring any resources to do what you want - regarding MFC or OS DLLs, aso.
0
 
LVL 5

Assisted Solution

by:AbqBill
AbqBill earned 213 total points
ID: 24577650
Hi, the answer depends on what you mean by 'DOS'. What operating system is booting from your CD? Is it really MS-DOS, or something like WinPE? If you need a Windows-based OS version testing utility, you could try my OSTEST program. It returns an exit code (ERRORLEVEL) based on the parameters you specify. For example:

ostest -p NT -v 5.1 -g -s 2

The above command will return an exit code of 1 if the current operating system is Windows XP (i.e., Windows NT 5.1) service pack 2 or greater. You can get OSTEST from my utility set here:

http://www.westmesatech.com/wast.html

Hope this helps. Bill.
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 24579705
Hi Bill,

Would it identify which service pack.  I would need to know if the system was running SP1, SP2 or SP3
0
 
LVL 5

Assisted Solution

by:AbqBill
AbqBill earned 213 total points
ID: 24581904
Yes, it can, using the -s option (see previous example). Also, the -g option means "greater than," so:

ostest -p NT v 5.1 -s 2

Returns an ERRORLEVEL 1 if the current operating system is exactly Windows XP SP2. If you put "-g" (meaning "greater than") before "-s" (as in the previous example), then it will return ERRORLEVEL 1 if the current operating system is Windows XP SP2 or any later service pack.

Keep in mind that OSTEST tests the currently running operating system, not an arbitrary OS that happens to be installed on a hard drive partition. Bill.
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 25616913
If I boot from a WinVista recovery cd and use the command prompt.  I want to know the OS inc SP installed on the HDD - is that possible with your tool? Is that possible without your tool and only using the command prompt?
0
 
LVL 5

Assisted Solution

by:AbqBill
AbqBill earned 213 total points
ID: 25617530
Hi Moncapitaan, my tool detects the running OS, not an arbitrary one on an OS partition. To do what you want, you could do a version check on a system file using filever.exe or the FVerTest.exe in my toolset:

http://www.westmesatech.com/wast.html

It may be tricky to get the service pack -- you might have to examine the last modification date of a system file as well as its version number. Bill.
0
 
LVL 4

Author Comment

by:Moncapitaan
ID: 25743097
Need help awarding this one:-

I didnt get a solution to my problem exactly as I needed it.  AND now the problem no longer exists! HOWEVER Bill (AbqBill) was very helpful.  I dont want to accept the answer as the solution as it isnt but it is helpful :-)

??
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now