EricL Posted May 21, 2010 Share Posted May 21, 2010 Can someone confirm I am doing this right? Its not working but I dont know if its the script or what. I can not find an example that tries 2 admin accounts. expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win9x / NT ; Author: A.N.Other <myemail@nowhere.com> ; ; Script Function: ; Template AutoIt script. ; ; ---------------------------------------------------------------------------- ; Script Start ; ---------------------------------------------------------------------------- Opt("RunErrorsFatal", 0) ;Enables the Admin account checking to continue on vs. kicking out error and quiting DirCreate("c:\SvcTools\files") FileInstall("C:\Documents and Settings\USER\Desktop\scripts\AutoIT3\Jumpclient\xwin32.msi", "C:\SvcTools\files\") ; RunAsSet("administrator", @ComputerName, 'password1') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $PW = 0 Else RunAsSet("administrator", @ComputerName, 'password2') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $PW = 1 Else MsgBox(4096, "Admin account", "Unknown Admin Logon. Contact your administrator. ERROR:xclient") Exit EndIf EndIf ; If Not IsAdmin() Then If $PW = 0 Then RunAsSet('administrator', @Computername, 'password1') RunWait("msiexec /i C:\SvcTools\files\xwin32.msi") RunAsSet() Else RunAsSet('administrator', @Computername, 'password2') RunWait("msiexec /i C:\SvcTools\files\xwin32.msi") RunAsSet() EndIf Else RunWait("msiexec /i C:\SvcTools\files\xwin32.msi") EndIf Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 21, 2010 Share Posted May 21, 2010 What version of AutoIt are you using? RunAsSet() is no longer part of AutoIt. The credentials now go directly into the parameters of RunAs() or RunAsWait(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
EricL Posted May 21, 2010 Author Share Posted May 21, 2010 What version of AutoIt are you using? RunAsSet() is no longer part of AutoIt. The credentials now go directly into the parameters of RunAs() or RunAsWait().OH FFS 3.0 i think. I dont do much of this so I reuse old scripts to figure stuff out.if i upgrade i could lose all my old scripts? Link to comment Share on other sites More sharing options...
EricL Posted May 21, 2010 Author Share Posted May 21, 2010 DO you know an example i could use? do I still need: Opt("RunErrorsFatal", 0) and all this? RunAsSet("administrator", @ComputerName, 'password1') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $PW = 0 Else RunAsSet("administrator", @ComputerName, 'password2') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $PW = 1 Else MsgBox(4096, "Admin account", "Unknown Admin Logon. Contact your administrator. ERROR:xclient") Exit EndIf EndIf Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 21, 2010 Share Posted May 21, 2010 This is enough: If RunAs("UserName", @ComputerName, "Pa$$word", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then ; Worked ConsoleWrite("Worked..." & @LF) Else ; Failed ConsoleWrite("Failed..." & @LF) EndIf Assuming you have the current version of AutoIt. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
EricL Posted May 21, 2010 Author Share Posted May 21, 2010 This is enough: If RunAs("UserName", @ComputerName, "Pa$$word", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then ; Worked ConsoleWrite("Worked..." & @LF) Else ; Failed ConsoleWrite("Failed..." & @LF) EndIf Assuming you have the current version of AutoIt. Hmm.. guss i have to relean how to do this. I dont really understand everything going on there. Also I dont see how that tries two admin passwords to see which is right. Link to comment Share on other sites More sharing options...
99ojo Posted May 21, 2010 Share Posted May 21, 2010 (edited) Hmm.. guss i have to relean how to do this. I dont really understand everything going on there. Also I dont see how that tries two admin passwords to see which is right.Hi,have a look at helpfile. Code with the return values. Success: The PID of the process that was launched. Failure: Returns 0 and sets @error to non-zero. -> Start second try with second password...That's what Psalty's code does. Change the else tree to a second RunAs with the second password. Just get the returns of RunAs and recode.;-))StefanP.S: Heading for soup..... Edited May 21, 2010 by 99ojo Link to comment Share on other sites More sharing options...
EricL Posted June 14, 2010 Author Share Posted June 14, 2010 Hi, have a look at helpfile. Code with the return values. Success: The PID of the process that was launched. Failure: Returns 0 and sets @error to non-zero. -> Start second try with second password... That's what Psalty's code does. Change the else tree to a second RunAs with the second password. Just get the returns of RunAs and recode. ;-)) Stefan P.S: Heading for soup..... How does this look??? And thanks for all your help. Opt("RunErrorsFatal", 0) ;Enables the Admin account checking to continue on vs. kicking out error and quiting DirCreate("c:\SvcTools\files") FileInstall("C:\Documents and Settings\USER\Desktop\scripts\AutoIT3\Jumpclient\xwin32.msi", "C:\SvcTools\files\") ; If IsAdmin() Then RunWait("msiexec /i C:\SvcTools\files\xwin32.msi") EndIf ; If RunAs("Administrator", @ComputerName, "Password#1", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then RunAsWait( "administrator","password#1","0","msiexec /i C:\SvcTools\files\xwin32.msi") Else If RunAs("Administrator", @ComputerName, "Password#2", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then RunAsWait( "administrator","password#2","0","msiexec /i C:\SvcTools\files\xwin32.msi") Else MsgBox(4096, "Admin account", "Unknown Admin Logon. Contact your administrator. ERROR:xclient") EndIf EndIf Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 14, 2010 Share Posted June 14, 2010 That's going to run it twice, if the user is already an admin. Take advantage of ElseIf: If IsAdmin() Then RunWait("msiexec /i C:\SvcTools\files\xwin32.msi") ElseIf RunAs("Administrator", @ComputerName, "Password#1", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then RunAsWait("administrator", "password#1", "0", "msiexec /i C:\SvcTools\files\xwin32.msi") ElseIf RunAs("Administrator", @ComputerName, "Password#2", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then RunAsWait("administrator", "password#2", "0", "msiexec /i C:\SvcTools\files\xwin32.msi") Else MsgBox(4096, "Admin account", "Unknown Admin Logon. Contact your administrator. ERROR:xclient") EndIf Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
EricL Posted June 14, 2010 Author Share Posted June 14, 2010 That's going to run it twice, if the user is already an admin. Take advantage of ElseIf: If IsAdmin() Then RunWait("msiexec /i C:\SvcTools\files\xwin32.msi") ElseIf RunAs("Administrator", @ComputerName, "Password#1", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then RunAsWait("administrator", "password#1", "0", "msiexec /i C:\SvcTools\files\xwin32.msi") ElseIf RunAs("Administrator", @ComputerName, "Password#2", 0, @ComSpec & " /c VER", @WorkingDir, @SW_HIDE) Then RunAsWait("administrator", "password#2", "0", "msiexec /i C:\SvcTools\files\xwin32.msi") Else MsgBox(4096, "Admin account", "Unknown Admin Logon. Contact your administrator. ERROR:xclient") EndIf Thats way sexier.. Thanks again! and duh. that was kind of dumb of me as far as running it twice. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now