Clean Batch File - Deploying Service Pack 1 for Win7x64Pro

I've got a basic computer startup script to deploy Windows 7 SP1:

\\svr\share$\win7sp1\windows6.1-kb976932-x64.exe /quiet /nodialog /forcerestart

I want to add something ahead of this line to have the script check whether SP1 is already installed, and if it is, to terminate the script entirely.  Can this still be done w/ batch or does it have to be done with VBS?  What's the syntax?
Who is Participating?
CitizenRonConnect With a Mentor Commented:
There's a few ways it can be done, mostly all dealing with server pack or build numbers.

Here's my stab at it using a one-line script, but it's a pretty hefty one-liner.  I went with a REG QUERY comparing the "CurrentBuildNumber" value since Microsoft actually started incrementing that when service packs are added since Microsoft Vista.  Windows 7 is "7600" and Windows 7 SP1 is "7601".

For /f "tokens=3 delims= " %%A In ('REG QUERY "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /V CurrentBuildNumber ^|Find "CurrentBuildNumber"') Do (If %%A LSS 7601 \\svr\share$\win7sp1\windows6.1-kb976932-x64.exe /quiet /nodialog /forcerestart)

Open in new window

Let me know if you need something additional such as OS type detection (WinVista, Win7, etc) as well
Chris DentPowerShell DeveloperCommented:
I can't speak for batch scripting really, but WMI knows. And you can get CMD to tell you it with:


If the output from that can be tested...

NAMEWITHELD12Author Commented:
I'll give this a shot on my dev box and post results
NAMEWITHELD12Author Commented:
Short and sweet, it seems to work like a charm..thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.