Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Strong Force Wsus - Client Update Wsus 3.0

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,51349
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> Strong Force Wsus - Client Update Wsus 3.0
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Strong Force Wsus - Client Update Wsus 3.0 - 8/30/2007 3:57:34 AM   
  jeferson.propheta

 

Posts: 11
Score: 0
Joined: 8/27/2007
Status: offline
'***************************************************************************************************
'Windows Update Force
'script Write by Jeferson Propheta
'04/02/2007
'
'Version History
'- Change Service Type to Automatic     - Create LOG
'- WUAUSERV service Instrumentation WMI - Reset Client ID
'- Re-Install WSUS AGENT
'- Delete SoftwareDistribuition Folder     - Check if Aready Ran Before
'- Wsus 3 Implementation
'Last Update 06/06/2007
'***************************************************************************************************



On Error Resume Next

CONST ForAppending = 8
Const ForReading   = 1
Set objShell       = CreateObject("WScript.Shell")

strPatchFile       = objShell.ExpandEnvironmentStrings("%SystemDrive%") & ("\WsusCID.txt")
strRunFile         = objShell.ExpandEnvironmentStrings("%SystemDrive%") & ("\WsusRUN.txt")
strWsusAgentFile   = "\\SERVER_NAME_HERE\Change_HERE\WSUS\WindowsUpdateAgent30-x86.exe /wuforce /quiet /norestart"
strLogPatchFile    = "\\SERVER_NAME_HERE\Change_HERE\WSUS\%computername%_%username%.log"
strAgPatchFile     = "\\SERVER_NAME_HERE\Change_HERE\WSUS\AgentIntall-%computername%_%username%.log"

Set objAready      = CreateObject("Scripting.FileSystemObject")

           objShell.run "%ComSpec% /C date/t >>" & strLogPatchFile,0 ,True
           objShell.run "%ComSpec% /C sc query wuauserv >>" & strLogPatchFile,0 ,True

If NOT objAready.FileExists(strRunFile) Then

    If NOT objAready.FileExists(strPatchFile) Then
           objShell.run "net stop wuauserv",0 ,True
           Wscript.Sleep 3000
           objShell.Run "%ComSpec% /C set computername >" & strPatchFile,0 ,True
           objShell.RegDelete ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\AccountDomainSid")
           objShell.RegDelete ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientId")
     End If

           strComputer = "."
       Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
       Set colServices   = objWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name = 'wuauserv'")
           ServiceError  = 1
       For Each objService in colServices
           ServiceError  = 0
           errReturnCode = objService.StopService()
         Next

         If ServiceError = 1 then
           objShell.run "%ComSpec% /C start" & strWsusAgentFile,0 ,true
           objShell.Run "%ComSpec% /C date/t >>" & strAgPatchFile,0 ,True
           Wscript.Quit
         End IF


           objShell.run "%ComSpec% /C sc config wuauserv start= Auto",0
           objShell.run "sc config wuauserv start= Auto",0
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\ElevateNonAdmins","00000001","REG_DWORD"
           objShell.RegDelete ("HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AUOptions")
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\AUOptions","00000004","REG_DWORD"
           objShell.RegDelete ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\NextDetectionTime")
'version 13 Change
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\WUServer","http://WSUS_SERVER_NAME_HERE","REG_SZ"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\WUStatusServer","http://10.215.240.39","REG_SZ"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\ElevateNonAdmins","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AcceptTrustedPublisherCerts","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\NoAutoUpdate","00000000","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\AUOptions","00000004","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\ScheduledInstallDay","00000000","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\ScheduledInstallTime","00000003","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\UseWUServer","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\RescheduleWaitTimeEnabled","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\RescheduleWaitTime","00000005","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\NoAutoRebootWithLoggedOnUsers","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\DetectionFrequencyEnabled","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\DetectionFrequency","00000016","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\AutoInstallMinorUpdates","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\RebootRelaunchTimeoutEnabled","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\RebootRelaunchTimeout","0000001e","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\RebootWarningTimeout","0000000f","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\RebootWarningTimeoutEnabled","00000001","REG_DWORD"
           objShell.RegWrite   "HKLM\SOFTWARE\Policies\Microsoft\windows\WindowsUpdate\AU\IncludeRecommendedUpdates","00000001","REG_DWORD"


           objShell.run "%ComSpec% /C rd /S /Q %SystemRoot%\SoftwareDistribution",0
       strComputer = "."
           Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
           Set colServices   = objWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE Name = 'wuauserv'")
           For Each objService in colServices
           errReturnCode = objService.StartService()
           Next

       Set updateSession  = CreateObject("Microsoft.Update.Session")
       Set updateSearcher = updateSession.CreateupdateSearcher()
       Set searchResult   = updateSearcher.Search("IsInstalled=0 and Type='Software'")

         For I = 0 To searchResult.Updates.Count-1
             Set update = searchResult.Updates.Item(I)
         Next

       Set updatesToDownload = CreateObject("Microsoft.Update.UpdateColl")

         For I = 0 to searchResult.Updates.Count-1
             Set update = searchResult.Updates.Item(I)
                 updatesToDownload.Add(update)
         Next

       Set downloader = updateSession.CreateUpdateDownloader()
           downloader.Updates = updatesToDownload
           On Error Resume Next
           downloader.Download()

         For I = 0 To searchResult.Updates.Count-1
             Set update = searchResult.Updates.Item(I)
             If update.IsDownloaded Then
             End If
         Next

       Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")

         For I = 0 To searchResult.Updates.Count-1
             Set update = searchResult.Updates.Item(I)
             If update.IsDownloaded = true Then
                updatesToInstall.Add(update)
             End If
         Next

       Set installer = updateSession.CreateUpdateInstaller()
           installer.Updates  = updatesToInstall
           On Error Resume Next
       Set installationResult = installer.Install()
           objShell.run "wuauclt.exe /ResetAuthorization /DetectNow",0
           objShell.run "wuauclt.exe /ReportNow",0
           ServiceError = 0

        objShell.Run "%ComSpec% /C set computername >" & strRunFile,0 ,True
End If

Set objAready      = Nothing
Set objShell       = Nothing
Wscript.Quit


      

< Message edited by jeferson.propheta -- 8/30/2007 4:12:59 AM >


_____________________________

Wscript.Echo("Just4 Fun")
 
 
Revisions: 2 | Post #: 1
 
 RE: Strong Force Wsus - Client Update Wsus 3.0 - 8/30/2007 7:34:53 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
why not make those regwrites neater


      

(in reply to jeferson.propheta)
 
 
Post #: 2
 
 RE: Strong Force Wsus - Client Update Wsus 3.0 - 8/30/2007 9:45:17 PM   
  jeferson.propheta

 

Posts: 11
Score: 0
Joined: 8/27/2007
Status: offline
Sounds Perfect!!! thanks!

_____________________________

Wscript.Echo("Just4 Fun")

(in reply to gdewrance)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> Strong Force Wsus - Client Update Wsus 3.0 Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts