mbusse Posted March 9, 2004 Share Posted March 9, 2004 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.. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 9, 2004 Developers Share Posted March 9, 2004 (edited) 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 $RC=RunWait($PATCH,'',@SW_HIDE) If @error = 1 Then MsgBox(48,"Error","cannot start the installation because you are not in Admin mode.") Else MsgBox(0,"Done","Program finished with rc:" & $RC ) EndIf Edited March 9, 2004 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. Link to comment Share on other sites More sharing options...
mbusse Posted March 9, 2004 Author Share Posted March 9, 2004 OK, nothing similar in V2 as what you posted for V3? Guess it's time to learn V3.. Thanks for the quick response.. Mark.. Link to comment Share on other sites More sharing options...
Majai Posted March 10, 2004 Share Posted March 10, 2004 (edited) 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 Exit ; Here is the actual command to run as an admin. PatchInstall: 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 SplashTextOff ;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 March 10, 2004 by Majai Link to comment Share on other sites More sharing options...
mbusse Posted March 11, 2004 Author Share Posted March 11, 2004 majai, thanks for the response, I will try this.. Link to comment Share on other sites More sharing options...
Majai Posted March 11, 2004 Share Posted March 11, 2004 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") Link to comment Share on other sites More sharing options...
Guest itdsys Posted June 11, 2004 Share Posted June 11, 2004 ;Open up Explorer pointed to the install program Runwait,explorer /n \,/select \, %InstallServer%\\Application\\Microsoft\\ie6.0\\ie6setup.exe SetTitleMatchMode, 2 WinWait,6.0,,120 IfEqual,ERRORLEVEL,1,GoTo,Denied SetTitleMatchMode, 1 ;Keyboard shortcut to right clicking -- the run as menu is under shift right click Sleep,3000 SetKeyDelay,50 Send,{SHIFTDOWN}+{F10}{SHIFTUP} Sleep,3000 ;Choose Run As.. from the right click menu ;Send,a{ENTER};This works, but wasn't reliable Send,{DOWN}{DOWN}{ENTER} WinWait,Run As Other User,,150 IfEqual,ERRORLEVEL,1,GoTo,SlowConnection ;Enter the administrator rights login information Send,{TAB} Send,admin Send,{TAB} Send,PWD Send,{TAB} Send,DOMAIN Send,{TAB} Send,{ENTER} Link to comment Share on other sites More sharing options...
Beastmaster Posted June 11, 2004 Share Posted June 11, 2004 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. A2 -> A3A2 -> AHK (to be backward compatible) -> A3 Link to comment Share on other sites More sharing options...
Recommended Posts