Is there is a way to get service pack number from command line? Or the build number from command line (from which I can tell the service pack number (see http://superuser.com/questions/61944/how-do-i-determine-windows-version-and-service-pack-from-windowsupdatelog-txt))?

Upon starting cmd, part of the windows version number is printed on screen, but not the service pack number.

I want a non-powershell answer, but I wouldn't mind knowing about a power-shell answer anyways since some computers I deal with do have it installed.

link|improve this question

Other related websites: eggheadcafe.com/software/aspnet/29718402/… and support.microsoft.com/kb/279631 – Thr4wn Oct 18 '10 at 18:56
feedback

4 Answers

up vote 4 down vote accepted

systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

Source: http://www.windows-commandline.com/2009/01/find-windows-os-version-from-command.html

link|improve this answer
This is the only one that works on all computers I've tried these methods on. – Thr4wn Oct 8 '10 at 19:20
feedback

You can get it using WMIC - wmic os get servicepackmajorversion

For more on using WMIC, see this little tutorial: http://quux.wiki.zoho.com/WMIC-Snippets.html

link|improve this answer
Is wmic installed on all Windows computers? for some reason, my home computer does not recognize wmic. – Thr4wn Oct 1 '10 at 16:51
Awesome tool, thanks for sharing! @Thr4wn, according to Wikipedia, WMIC is not available on Windows XP Home Edition, but is available on XP Pro and all later versions of Windows. – nhinkle Oct 1 '10 at 20:18
feedback

You can type in CMD:

Winver

link|improve this answer
nice answer! .... +1 when i get more votes – studiohack Sep 30 '10 at 20:49
1  
Hm... problem with that is, it opens a GUI tool, which may not be what the user is attempting to do. – nhinkle Sep 30 '10 at 21:05
2  
SYSTEMINFO run in a command prompt will display without GUI. – r0ca Sep 30 '10 at 21:16
In cmd.exe you can use just ver and get the version on stdout. But you need to convert the build number to get the SP. – Richard Oct 1 '10 at 8:26
ver doesn't give the full version number. It stops right before the service pack number. – Thr4wn Oct 1 '10 at 16:49
show 1 more comment
feedback

You can get it from the command line by querying the registry for the ServicePack key. If an SP is installed, it will be shown, otherwise, it will say that it was unable to locate the specified key, in which case there is no service pack.

reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v ServicePack
link|improve this answer
This only works if there is a Service Pack installed (e.g. currently Windows 7 does not have a Service Pack so the key does not exist) – misterjaytee Oct 1 '10 at 11:14
I know; that's what I stated in my answer. If the key doesn't exist, then there is no service pack, thus it is SP0. If the key does exist, it'll tell you the service pack. So either way, you can figure out what service pack (if any) is installed. – nhinkle Oct 1 '10 at 20:17
When I try Giri's solution, it shows SP 3, but this method reports that it was unable to find the specified registry key or value (I copied/pasted the command into cmd). – Thr4wn Oct 8 '10 at 19:19
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.