Tuesday, March 29, 2011

AutoIT Example 2. Windows Update Automation Using Variables

Code:

Global $admin, $password, $program, $program2
$admin = "Administrator"
$password = "password" 
  ; change password to the password for the
  ; Administrator account

  ; change the following program names to the 
  ; actual filenames of 2 Windows updates
$program = "Windows Update 1.exe /passive /norestart"
$program2 = "Windows Update 2.exe /passive /norestart"

  If @Username <> "Administrator" Then
    RunAsSet($admin,@ComputerName,$password)
    install()
    RunAsSet()
  Else
    install()
  EndIf

  Func install()
    RunWait($program)
    RunWait($program2)
  EndFunc

No comments:

Post a Comment