Jump to content
Sign in to follow this  

Pushing A Windows Update That Needs Admin Privileg

Recommended Posts

OK, I have a question about pushing a windows update that needs admin privileges. I recently used autoit to push some windows updates to our remote sales people, what I failed to realize is they do not have admin rights, is there a way to run the update in autoit as admin?

I appreciate any input on this.. Mark..

Share this post

Link to post
Share on other sites

The best option is to switch to Version 3, then you have the command RunAs.

EDIT:an example

$USERNAME="?????"    ; local admin account name
$PASSWORD="????????"; local admin account psw
$PATCH="xyz.exe"    ; Program to run
RunAsSet($USERNAME, @ComputerName, $PASSWORD)
; Run CMD to test credentials if fails then exits
If @error = 1 Then
   MsgBox(48,"Error","cannot start the installation because you are not in Admin mode.")   
   MsgBox(0,"Done","Program finished with rc:" & $RC )   
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
Live for the present,
Dream of the future,
Learn from the past.

Share this post

Link to post
Share on other sites

OK, nothing similar in V2 as what you posted for V3?

Guess it's time to learn V3..

Thanks for the quick response..


Share this post

Link to post
Share on other sites

I do it all the time here is the trick i have it call a batch file as the admin because i have not had much luck with autoItV2 and DOS switches. I usually also run a inventory script that checks if the patch is installed as well with autoIT. So here is my break out of it all.

;Patch checking section is like this

RegRead, NovPatch, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\KB823182, Description

RegRead, NovPatch1, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\KB824141, Description

RegRead, NovPatch2, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\KB825119, Description

RegRead, NovPatch3, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\KB826232, Description

RegRead, NovPatch4, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\KB828035, Description

RegRead, NovPatch5, REG_SZ, HKEY_LOCAL_MACHINE, SOFTWARE\\Microsoft\\Updates\\Windows 2000\\SP5\\KB828749, Description

;He is where i check the values from above to see if it equals anything if not it installs

IFEqual, Novpatch, , Goto, PatchInstall

IFEqual, Novpatch1, , Goto, PatchInstall

IFEqual, Novpatch2, , Goto, PatchInstall

IFEqual, Novpatch3, , Goto, PatchInstall

IFEqual, Novpatch4, , Goto, PatchInstall

IFEqual, Novpatch5, , Goto, PatchInstall


; Here is the actual command to run as an admin.


Run, runas /user:Domain\\AdminName \\\\Location of Batch script

Sleep, 3000

WinActivate, C:\\WINNT\\System32\\runas.exe

send, password{ENTER}

Sleep, 1000

SplashTextOn, 550, 150, "Patch installation", "Please standby while we install security patches on your system. Thank you"

Sleep, 30000


;Now the batch script i call will look something like this on each patch.

@echo Off

Start "patch1" /MIN /SEPARATE /HIGH /WAIT "\\ServerName\KB823182.exe" /u /f /z

Good luck with it.

Edited by Majai

Share this post

Link to post
Share on other sites

Thats how u do it in version2 its pretty ulgy. Now version 3 is a whole lot easier. You can set all the variables like JdeB does and return an error if they are not an admin. I prefer the KISS method so here it is very simply to get it to run as an admin

RunAsSet("UserName", "Domain", "Password")

RunWait("Location of patch you want to run you can include switches")

Share this post

Link to post
Share on other sites
Guest itdsys

;Open up Explorer pointed to the install program
Runwait,explorer /n \,/select \, %InstallServer%\\Application\\Microsoft\\ie6.0\\ie6setup.exe
SetTitleMatchMode, 2
SetTitleMatchMode, 1
;Keyboard shortcut to right clicking -- the run as menu is under shift right click
;Choose Run As.. from the right click menu
;Send,a{ENTER};This works, but wasn't reliable
WinWait,Run As Other User,,150
;Enter the administrator rights login information

Share this post

Link to post
Share on other sites

As this is Jon's forum and AutoIt 3 is the legitimate follower of AutoIt 2, and to provide the whole picture - AutoHotkey (also based on Jon's genius) provides that command as well (while it's backward compatible to A2)

RunAs - Specifies a set of user credentials to use for all subsequent uses of Run and RunWait. 2000/XP or later ONLY.

So you've an additional option of a smooth transition to A3 via AHK. Happy scripting. :D

A2 -> A3

A2 -> AHK (to be backward compatible) -> A3

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...