Sign in to follow this  
Followers 0
Mark Mears

RunAsSet Credential Check

7 posts in this topic

Hi all,

We have remote users that require security patches. I have created a script that uses the RunAsSet function to run the patches in the context of the local Administrator account to be distributed to the users on a CD. This script is then compiled and run as an EXE file to ensure the password of this account is not compromised. While most of the users have a standardized password, some of the machines' admin accounts have not been updated to reflect the current password.

Is there a way to check to see if the RunAsSet function has been successful in setting the credentials correctly? I have the following in my script:

*******************

Opt("RunErrorsFatal", 0)

$Username = "Administrator"

$Password = "Passw0rd"

; Set the RunAs parameters to use local adminstrator account

RunAsSet($Username, @Computername, $Password)

If @Error = 1 Then

SetError(0)

MsgBox(4096, "Unknown Credentials", "Incorrect password supplied. Please notify the Help Desk.")

Exit

Endif

*****************

My problem is that in testing this with a different password on the account, when I am expecting this to fail, I am unable to trap this condition and the script fails to produce any notification. Checking the @error macro in a MsgBox shows it at a 0 value.

What I need is a way to check to see if the RunAsSet function was able to successfully set the credentials. If the credentials were not successfully set then I need to give the user a notification that they need to either run an alternate script or notify the Help Desk so the password can be reset. If the credentials are correct, the script runs fine!

Any takers?

Thanks in advance!

Mark

Share this post


Link to post
Share on other sites



That works like I was hoping! Thanks!

Mark

Share this post


Link to post
Share on other sites

I have the same problem and checked the link and didn't find the solution...

What exactly did you do in the end mark ?

Thx

Share this post


Link to post
Share on other sites

nevermind I got it :P

Share this post


Link to post
Share on other sites

Hey Ainner,

Can you let me know what worked for you. I looked further into the docs and found the the solution I had tried actually did not work. The Opt() function return value is documented in the Help file as the value of the previous stored value.

In my case, I started with the default value of 1 and reset the value to 0. When I assigned the variable to the return value of the function, it returned the previous value ("1") which appeared to work for me when I tried to test with an incorrect password. A correct password returned the same value which indicates to me that this is NOT the correct way to check for the correct password.

Does anybody have a manner of verifying the RunAsSet credentials?

Thanksm,

Mark

Share this post


Link to post
Share on other sites

AutoItSetOption ( "RunErrorsFatal", 0 )

passwd = InputBox("Contrôle de sécurité", "Entrer un mot de passe : ", "", "*")

RunAsSet("MSSSa", @Computername, $passwd)

$pid=Run ( 'C:\Program Files\Internet Explorer\iexplore.exe c:\', 'C:\Program Files\Internet Explorer' )

If $pid = 0 Then

MsgBox(4096,"Mot de passe invalide","Le mot de passe entré est invalide...")

Exit

EndIf

Here's how I did it...

You just need to check if the run program return the zero value...

Hope it help...

Share this post


Link to post
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
Sign in to follow this  
Followers 0