Jump to content
Sign in to follow this  
JHager

WUSA and AutoIt

Recommended Posts

JHager

Hi Folks,

Trying to get wusa to runwait with .msu patches. I have been using a script for XP machines that works flawlessly. However, as you all know, with WIN7 they introduced wusa.exe for the msu packages. I have seen very little regarding this issue so, I thought I would throw this out there. I know this is a long string of code, but I would dearly appreciate any help that you may recommend. Thanks in advance. This is my script for XP:

#include <array.au3>
; 1) $debug=1 for on screen status, $debug=0 for silent
$debug=0
; path for scan32
$scan32="F:DATASharedAuditWizScanscanscan32.exe"
; 2) $logPath = path for patch install status. don't forget the trailing slash
;    if patch is good, log will have extension of .ook - if any failed, will have extension of .bad
$logPath="c:"
; 3) $patchPath for full path to executables ***remember to include trailing slash*** 
$patchPath="F:WINAPPSMSupdateWinXPUpPostSP32-14-12"
; 4) enter only the patch name, not the extention - ie. kb666 not kb666.exe 
;    remember to change the Dim $aPatches[x] statement to reflect the total number of patches
Dim $aPatches[2]
$aPatches[0]="KB2660465"
$aPatches[1]="KB2661637"
; $aPatches[2]=""
; $aPatches[3]=""
If $debug Then
  _ArrayDisplay ($aPatches,"$aPatches")
  EndIf
; 5) enter the runtime options for the patches. if necessary, run the patch from a cmd prompt - ie. kb666 /?
;    remember to change the Dim $aOptions[x] statement to reflect the total number of patches
Dim $aOptions[2]
$aOptions[0]=" /quiet /norestart /overwriteoem"
$aOptions[1]=" /quiet /norestart /overwriteoem"
; $aOptions[2]=""
; $aOptions[3]=""
If $debug Then
  _ArrayDisplay ($aOptions,"$aOptions")
  EndIf
$logFile=StringTrimRight(@ScriptName, 4)
$logFileExtension=".ook" 
$audit=1 ; if it changes to 1 then scan32.exe will run afterwards
If $debug Then
  MsgBox(0,"log file",$logPath & $logFile & $logFileExtension)
  EndIf
$file = FileOpen($logPath & $logFile & $logFileExtension,1)
FileWriteLine($file, "Patch Program: " & @ScriptName & @CRLF & _ 
    "Patch Path: " & $patchPath & @CRLF & _
                     "Computer Name: " & @ComputerName & @CRLF & _ 
"Date: " & @MDAY & "-" & @MON & "-" & @YEAR & @CRLF)
For $x = 0 to Ubound ($aPatches,1)-1
  If Not RegRead("HKEY_LOCAL_MACHINESOFTWAREUDAF",$aPatches[$x]) Then 
If $debug Then
 MsgBox(0,"","Installing " & $patchPath & $aPatches[$x] & $aOptions[$x])
      EndIf
$status = RunWait($patchPath & $aPatches[$x] & $aOptions[$x],"",@SW_HIDE)
$audit=1
    If $debug Then
 MsgBox(0,$aPatches[$x],"status: " & $status)
      EndIf
    If $status=0 or $status=3010 Then
      RegWrite("HKEY_LOCAL_MACHINESOFTWAREUDAF",$aPatches[$x], "REG_DWORD", "00000001")
      Else 
        $logFileExtension=".bad"
      EndIf
    FileWriteLine($file,$aPatches[$x] & " status:" & $status & @CRLF)
    Else 
    FileWriteLine($file,$aPatches[$x] & " was already installed" & @CRLF)
    If $debug Then
 MsgBox(0,"",$aPatches[$x] & " was already installed")
      EndIf
  EndIf
Next
FileWriteLine($file,"Finished" & @CRLF & @CRLF)
FileClose($file)
If $logFileExtension <> ".ook" Then
FileMove($logPath & $logFile & ".ook",$logPath & $logFile & $logFileExtension,1)
EndIf
If $audit Then
 Run($scan32,"",@SW_MINIMIZE)
EndIf

Now, below I have pasted what I have tried, incorporating wusa, resulting in various errors. Mainly, I receive, "Error: unable to execute external program". There are two scripts, using two different methods, neither seems to work. The WIN 7 scripts are truncated without all the other code that is inconsequential. Please see below:

First WIN7 script:

$patchPath="WinAppsMSupdateWIN72-14-12"
; 4) enter only the patch name, not the extention - ie. kb666 not kb666.exe 
;    remember to change the Dim $aPatches[x] statement to reflect the total number of patches
Dim $aPatches[1]
$aPatches[0]="KB2645640"
; $aPatches[1]=""
; $aPatches[2]=""
; $aPatches[3]=""
If $debug Then
  _ArrayDisplay ($aPatches,"$aPatches")
  EndIf
; 5) enter the runtime options for the patches. if necessary, run the patch from a cmd prompt - ie. kb666 /?
;    remember to change the Dim $aOptions[x] statement to reflect the total number of patches
Dim $aOptions[1]
$aOptions[0]=" /quiet /norestart"
; $aOptions[1]=""
; $aOptions[2]=""
; $aOptions[3]=""
If $debug Then
  _ArrayDisplay ($aOptions,"$aOptions")
  EndIf
$logFile=StringTrimRight(@ScriptName, 4)
$logFileExtension=".ook" 
If $debug Then
  MsgBox(0,"log file",$logPath & $logFile & $logFileExtension)
  EndIf
$file = FileOpen($logPath & $logFile & $logFileExtension,1)
FileWriteLine($file, "Patch Program: " & @ScriptName & @CRLF & _ 
    "Patch Path: " & $patchPath & @CRLF & _
                     "Computer Name: " & @ComputerName & @CRLF & _ 
"Date: " & @MDAY & "-" & @MON & "-" & @YEAR & @CRLF)
For $x = 0 to Ubound ($aPatches,1)-1
  If Not RegRead("HKEY_LOCAL_MACHINESOFTWAREUDAF",$aPatches[$x]) Then 
If $debug Then
 MsgBox(0,"","Installing " & $patchPath & $aPatches[$x] & $aOptions[$x])
      EndIf
$wusa = @SystemDir & "wusa.exe"
$status = RunWait($wusa & $patchPath & $aPatches[$x] & $aOptions[$x],"",@SW_HIDE)


Second WIN7 script:


$patchPath="F:WINAPPSMSupdateWinXPUpPostSP32-14-12"
; 4) enter only the patch name, not the extention - ie. kb666 not kb666.exe 
;    remember to change the Dim $aPatches[x] statement to reflect the total number of patches
Dim $aPatches[1]
$aPatches[0]="KB2645640"
; $aPatches[1]="KB2661637"
; $aPatches[2]=""
; $aPatches[3]=""
If $debug Then
  _ArrayDisplay ($aPatches,"$aPatches")
  EndIf
; 5) enter the runtime options for the patches. if necessary, run the patch from a cmd prompt - ie. kb666 /?
;    remember to change the Dim $aOptions[x] statement to reflect the total number of patches
; Dim $aOptions[2]
;$aOptions[0]=" /quiet /norestart /overwriteoem"
; $aOptions[1]=" /quiet /norestart /overwriteoem"
; $aOptions[2]=""
; $aOptions[3]=""
If $debug Then
  _ArrayDisplay ($aOptions,"$aOptions")
  EndIf
$logFile=StringTrimRight(@ScriptName, 4)
$logFileExtension=".ook" 
If $debug Then
  MsgBox(0,"log file",$logPath & $logFile & $logFileExtension)
  EndIf
$file = FileOpen($logPath & $logFile & $logFileExtension,1)
FileWriteLine($file, "Patch Program: " & @ScriptName & @CRLF & _ 
    "Patch Path: " & $patchPath & @CRLF & _
                     "Computer Name: " & @ComputerName & @CRLF & _ 
"Date: " & @MDAY & "-" & @MON & "-" & @YEAR & @CRLF)
For $x = 0 to Ubound ($aPatches,1)-1
  If Not RegRead("HKEY_LOCAL_MACHINESOFTWAREUDAF",$aPatches[$x]) Then 
If $debug Then
 MsgBox(0,"","Installing " & $patchPath & $aPatches[$x] & $aOptions[$x])
      EndIf
$wusa = @SystemDir & "wusa.exe"
$status = RunWait($wusa & " " & $patchPath & $aPatches[$x] & " /quiet /norestart")
Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites
Melba23

JHager,

Welcome to the AutoIt forum. :oops:

I cannot help you with the question - but I can with the formatting. When you post code all you have to do to get the pretty boxes (like the ones I have set for you above) is to use Code tags - put [autoit] before and [/autoit] after your posted code. :bye:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×