Jump to content

RunAsSet after determine current admin password


 Share

Recommended Posts

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 by EricL
Link to comment
Share on other sites

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

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 :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

RunAsWait() is part of the latest beta :D

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

  • Developers

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

:D

Edited 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

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

:D

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

  • Developers

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

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.

#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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...