Jump to content

Recommended Posts

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


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




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!


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?



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...")



Here's how I did it...

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

Hope it help...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...