install script (Full Version)

All Forums >> [Scripting Technologies] >> VB Script



Message


claudele -> install script (4/7/2008 9:11:56 AM)

claudele
I have a script that is suppose to run automatic updates from the local wsuscab and install the updates from that cab on a local file server. It  scans and downloads the updates but doesn't install, giving error number 4. In windows update log it reads Windows failed to install the following update with error 0x80246007:
thanks for any help.
Script is

Set UpdateSession = CreateObject("Microsoft.Update.Session")
Set UpdateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
Set UpdateService = UpdateServiceManager.AddScanPackageService("Offline Sync Service", "c:\wsusscn2.cab")
Set UpdateSearcher = UpdateSession.CreateUpdateSearcher()
'Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
WScript.Echo "Searching for updates..." & vbCRLF
UpdateSearcher.ServerSelection = 3
UpdateSearcher.ServiceID = UpdateService.ServiceID
Set SearchResult = UpdateSearcher.Search("IsInstalled=0")
Set Updates = SearchResult.Updates
If searchResult.Updates.Count = 0 Then
  WScript.Echo "There are no applicable updates."
  WScript.Quit
End If

'20
WScript.Echo "List of applicable items on the machine when using wssuscan.cab:" & vbCRLF
'*******************************************************************************
WScript.Echo vbCRLF & "Downloading updates..."

'*******************************************************************************
Set updatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
For I = 0 To searchResult.Updates.Count-1
  set update = searchResult.Updates.Item(I)
     WScript.Echo I + 1 & " adding:  " & update.Title
     updatesToInstall.Add(update) 
 
Next
'WScript.Echo "List of updates:" & updatesToInstall
'******************************************************************************
'39
WScript.Echo "Installing updates..."
Set installer = updateSession.CreateUpdateInstaller()
installer.Updates = updatesToInstall
      Set installationResult = installer.Install()
Wscript.echo " Close 2" 
For I = 0 to updatesToInstall.Count - 1
WScript.Echo I + 1 & "> " & _
updatesToInstall.Item(i).Title & _
": " & installationResult.GetUpdateResult(i).ResultCode
Next
'Output results of install
WScript.Echo "Installation Result: " & installationResult.ResultCode
WScript.Echo "Reboot Required: " & installationResult.RebootRequired & vbCRLF    

WScript.Quit




rtruss -> RE: install script (4/7/2008 10:23:07 AM)

Not sure what to tell you.  I just tested your script and after changing the & to just & it worked flawlessly.  Mind you my systems was vista and it is fully patched so nothing was needed.




claudele -> RE: install script (4/7/2008 11:50:02 AM)

Its running on XP that needs 2 updates from the cab and it is not installing. It runs without errors but its not executing installation. Thanks for the feedback rtruss




charlesanh -> RE: install script (4/24/2008 11:11:41 AM)

Claudele, did you every figured it out.  I am having the saving issues.  I can't install after the scan when working offline.  I was able to do this to trick the script.  I got online with network laptop and downloaded the update i needed.  I moved that update to the download folder under SoftwareDistribution on my offline laptop.  I ran a similiar script to yours and it got install.  The question I have is why I can scan the local wsusscn2.cab to verify which updates is needed but can't install.  Does this not work on an offline machine. 
Set installer = updateSession.CreateUpdateInstaller()
installer.Updates = updatesToInstall 
Set installationResult = installer.Install()

Thanks for any help,
ATD




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.203125