EricL Posted April 29, 2008 Share Posted April 29, 2008 (edited) on my network I have a few local admin passwords on clients. I want to do a runasset to execute the setup as a local admin. however over time the pw change and I have 2 different passwords. Is there a way i can test the local admin, and get a result returned fail or pass. basically... ;Vista if @OSVersion = "WIN_VISTA" Then RunAsSet('administrator', @Computername, 'password1') RunWait("msiexec /i C:\file.msi /qb+!") Else If Not IsAdmin() Then IF <<<< insert test string?>>>> Then RunAsSet('administrator', @Computername, 'password1') run("msiexec /i C:\file.msi /qb+!") ELSE RunAsSet('administrator', @Computername, 'password2') run("msiexec /i C:\file.msi /qb+!") Else run("msiexec /i C:\file.msi /qb+!") EndIf EndIf RunAsSet() I may be way off.. please advise. Also does the code look right? I never did anything this complicated yet. still learning. TIA! Edited April 29, 2008 by EricL Link to comment Share on other sites More sharing options...
monoceres Posted April 29, 2008 Share Posted April 29, 2008 This work but it's a bit ugly: First compile this code: #RequireAdmin Exit 1oÝ÷ Ù8^*.q©î±ëayì^)¶¬jëh×6$code=RunAsWait("Andreas",@ComputerName,"password",0,"nameofcompiledexe.exe") If $code=1 Then MsgBox(0,"","Right pass!") Else MsgBox(0,"","Wrong pass :(") EndIf Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
EricL Posted April 29, 2008 Author Share Posted April 29, 2008 This work but it's a bit ugly: First compile this code: #RequireAdmin Exit 1oÝ÷ Ù8^*.q©î±ëayì^)¶¬jëh×6$code=RunAsWait("Andreas",@ComputerName,"password",0,"nameofcompiledexe.exe") If $code=1 Then MsgBox(0,"","Right pass!") Else MsgBox(0,"","Wrong pass :(") EndIf Im trying this.. did you mean to put the last part? you can run the exe from teh RunAsSet function? I assume you meant RunAsSet since RunAsWait does not exist? Thanks for your help! Link to comment Share on other sites More sharing options...
monoceres Posted April 29, 2008 Share Posted April 29, 2008 Im trying this.. did you mean to put the last part? you can run the exe from teh RunAsSet function? I assume you meant RunAsSet since RunAsWait does not exist?Thanks for your help!RunAsWait() is part of the latest beta Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
EricL Posted April 29, 2008 Author Share Posted April 29, 2008 RunAsWait() is part of the latest beta oh. heh.Is there a way to do it w/ non-beta?I tried it a few ways and the problem is its generating errors that logon is no good (popup erros then exit.)I cant get it to just keep chugging to the else statement. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 29, 2008 Developers Share Posted April 29, 2008 (edited) Something like this should work" RunAsSet("ID1", @ComputerName, 'Psw1') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $Cur_SEQ = 0 Else RunAsSet("ID2", @ComputerName, 'Psw2') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $Cur_SEQ = 1 Else MsgBox(4096, "Admin account", "Unknown") Exit EndIf EndIf Edited April 29, 2008 by Jos 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...
EricL Posted April 29, 2008 Author Share Posted April 29, 2008 Something like this should work" RunAsSet("ID1", @ComputerName, 'Psw1') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $Cur_SEQ = 0 Else RunAsSet("ID2", @ComputerName, 'Psw2') RunWait(@ComSpec & " /c dir ", "", @SW_HIDE) If @error = 0 Then $Cur_SEQ = 1 Else MsgBox(4096, "Admin account", "Unknown") Exit EndIf EndIf Ok i tried to follow this. I think i get it. not 100% sure what this does "RunWait(@ComSpec & " /c dir ", "", @SW_HIDE)" but I dont think sw_hide worked. I get the same error as before. popup that says it was unable to execute the comspec runwait command due to logon error. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 29, 2008 Developers Share Posted April 29, 2008 You need this at the top of the script to tell AUtoIt to continue on RUN errors: Opt("RunErrorsFatal", 0) Jos 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...
EricL Posted April 29, 2008 Author Share Posted April 29, 2008 You need this at the top of the script to tell AUtoIt to continue on RUN errors: Opt("RunErrorsFatal", 0) Jos Money! Sweet thanks!!! Link to comment Share on other sites More sharing options...
Developers Jos Posted April 29, 2008 Developers Share Posted April 29, 2008 Money! Sweet thanks!!!enjoy 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...
bikester Posted April 30, 2008 Share Posted April 30, 2008 I need to share this since i spent a fair amount of time looking for the same type of solution. The basis of this script came from another user and i can't find the original post right now. We have a couple thousand pc's and maybe a total of 10 possible passwords that could be on the local administrator account or on other admin accounts. Now that i have this working, it is in every installer package i make. I obfuscate and compile before releasing to the masses, or running in a script. Just add as many username / password combos that you need. It allows you to purposely have many different admin logins so that if one is compromised, your entire network is not at risk. I made a special admincheck utility out of this, that actually displays the correct username and password so you don't spend 15 mins trying different ones. Obviously that is a super secret program just for the techs. expandcollapse popup#include <Array.au3> Global $user, $pw AdminCheck() If $user="unknown" or $user="" Then MsgBox(0, "", "Authentication Error") Exit EndIf RunAsSet($user, @ComputerName, $pw, 0) RunWait(@ComSpec & " /c " & "c:\temp\setup.exe", "", @SW_HIDE) ; ==> end of script Func AdminCheck() Opt("RunErrorsFatal", 0) Global $user="unknown", $pw="unknown" Local $avAdmins[1] _ArrayAdd($avAdmins, "admin1,password1") _ArrayAdd($avAdmins, "admin2,password2") _ArrayAdd($avAdmins, "admin3,password3") For $i = 1 to UBound($avAdmins) - 1 $AdminTest = StringSplit($avAdmins[$i], ",") RunAsSet($AdminTest[1], @ComputerName, $AdminTest[2], 0) RunWait(@ComSpec & " /c " & "echo Running on the "& $AdminTest[1] &" account!>"&@WindowsDir&"\au3admchk.tmp", "", @SW_HIDE) If not @error Then Global $user = $AdminTest[1] Global $pw = $AdminTest[2] ExitLoop EndIf Next Opt("RunErrorsFatal", 1) If FileExists(@WindowsDir &"\au3admchk.tmp") Then RunAsSet($user, @ComputerName, $pw, 0) Run(@ComSpec & " /c del " & @WindowsDir & "\au3admchk.tmp", "", @SW_HIDE) EndIf RunAsSet() EndFunc Link to comment Share on other sites More sharing options...
EricL Posted April 30, 2008 Author Share Posted April 30, 2008 There is stuff in there that I dont understand yet. ie; #include etc. I am very glad you posted this as i will try and figure it out if i need more than the current 2 local pw's. Thanks alot! 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