Aero Posted October 26, 2005 Share Posted October 26, 2005 Hey guys! I know there is a way to do this but dont have a clue where to start.What Im trying to do is make a batch script that will install all of the official windows updates silently on an existing machine. So far i have gotten it to work for all of the post SP2 updates and everything will install just fine if SP2 is installed on the machine. Im looking for a way to tell my script to get the windows version, determine if it has SP2 installed and if it does not, give some kind of message stating that SP2 is not installed. Any ideas? Link to comment Share on other sites More sharing options...
gunsmokingman Posted October 26, 2005 Share Posted October 26, 2005 (edited) Here a VBS script that list the Installed HotfixesSave as HotFixes_Installed.VBSstrComputer = "." Dim Act, SD, Fso, Ts Set Act = CreateObject("Wscript.Shell") Set Fso = CreateObject("Scripting.FileSystemObject") SD = Act.ExpandEnvironmentStrings("%Systemdrive%") Set Ts = Fso.CreateTextFile(SD & "\Installed_HotFixes.txt") Ts.WriteLine Space(5) & Time() & " <-----> " & Date() Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colQuickFixes = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering") For Each objQuickFix in colQuickFixes Ts.WriteLine "Computer: " & objQuickFix.CSName Ts.WriteLine "Description: " & objQuickFix.Description Ts.WriteLine "Hot Fix ID: " & objQuickFix.HotFixID Ts.WriteLine "Installation Date: " & objQuickFix.InstallDate Ts.WriteLine "Installed By: " & objQuickFix.InstalledBy Next If colQuickFixes.count = 0 Then Ts.WriteLine "No hot fixes where found" End If Ts.Close Act.Run(SD & "\Installed_HotFixes.txt"),1,True Keep = Act.Popup("Did you want to keep the" & vbCrLf & "Installed_HotFixes.txt" &_ vbcrlf & "Yes to keep the Installed_HotFixes.txt" & vbCrLf & "No to delete the Installed_HotFixes.txt" &_ vbCrLf & "If nothing is selected in 15 seconds" & vbCrLf & "The defualt action is to keep" &_ vbCrLf & "Installed_HotFixes.txt", 15, "Keep Or Delete", 4 + 32) If Keep = Vbyes Then End If If Keep = Vbno Then Fso.DeleteFile(SD & "\Installed_HotFixes.txt") End If If Keep = -1 Then End If Edited October 26, 2005 by gunsmokingman Link to comment Share on other sites More sharing options...
SilverBulletUK Posted October 26, 2005 Share Posted October 26, 2005 (edited) What about....@Echo OffIF EXIST %WINDIR%\Driver~1\i386\SP2.CAB GOTO SP2YESGOTO SP2NO:SP2YESSET SP2STATUS=YesGOTO OUTPUT:SP2NOSET SP2STATUS=NoGOTO OUTPUT:OUTPUTClsEcho.Echo Does this machine have Service Pack 2 you ask?Echo.Echo %SP2STATUS%Echo.PauseExitNice and simple i know, but, does the trick....! Edited October 26, 2005 by SilverBulletUK Link to comment Share on other sites More sharing options...
gunsmokingman Posted October 26, 2005 Share Posted October 26, 2005 Mine list all the hotfixes installed on the machine, not just one. It also produces a report of all the hotfixes installed. Link to comment Share on other sites More sharing options...
SilverBulletUK Posted October 26, 2005 Share Posted October 26, 2005 Yeah I see that gunsmokingman, and very nice it is too, it just seems overkill for what he is actually asking for....Maybe he needs all the extra info your script can provide him....who knows. Link to comment Share on other sites More sharing options...
Yzöwl Posted October 26, 2005 Share Posted October 26, 2005 wmic os get CSDVersion | find "Service Pack 2" >nul || echo/ Service Pack 2 is not installed Link to comment Share on other sites More sharing options...
cluberti Posted October 26, 2005 Share Posted October 26, 2005 Get osverex from the zip file located here:http://internet.cybermesa.com/~bstewart/wast.htmlosverex.exe returns the OS as an exit code (11 for XP Pro), or the service pack level when run with the -s option. Easy to script. Link to comment Share on other sites More sharing options...
gunsmokingman Posted October 27, 2005 Share Posted October 27, 2005 To see if Service Pack 2 is installedstrComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem") For Each objOperatingSystem in colOperatingSystems MsgBox "Confirm Service Pack " & objOperatingSystem.ServicePackMajorVersion _ & "." & objOperatingSystem.ServicePackMinorVersion & " Is Installed", 0 + 32, "Confirm SP2" Next If colOperatingSystems.count = 0 Then MsgBox "Service Pack 2 Is Not Installed", 0 + 32, "Not SP2" End If Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now