Sign in to follow this  
Followers 0
Guest NU2Autoit

Bad Password Error

7 posts in this topic

I am writing a RunAsSet script to do an install using a local admin password. The first thing I do is open notepad using the RunAsSet credentials to verify the local admin password is correct. If the password is bad I get Logon Failure: unknown username or bad password, which is what is supposed to do. What I am looking for is something that will put up a message box telling the user to contact the help desk if the error occurs. Does anyone have any ideas that would point me in the right direction? Any help would be appreciated. Below is the current script.

$USERNAME = "Admin"

$Password = "password"

$Domain = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName")

select

Case @OSVersion = "WIN_2000"

Runasset ($username, $Domain, $password)

Run("C:\Winnt\Notepad.exe","",@SW_MINIMIZE )

Sleep(2000)

WinClose("Untitled - Notepad", "")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

This might work

; Set the RunAs parameters to use local adminstrator account
RunAsSet("admin", @Computername, "adminpassword")
$var=AutoItSetOption ( "RunErrorsFatal", 0 )
; Check if admin is ok
    If $var = 1 Then
        MsgBox(0, "Error", "Please contact Helpdesk")
    Exit
EndIf


; Run notepad as admin
RunWait("Notepad.exe","",@SW_MINIMIZE)
Sleep(2000)
WinClose("Untitled - Notepad", "") 

; Reset user's permissions
RunAsSet()
Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

EDIT: I forgot the beginning of my code when I pasted it:

Maybe something like this:

Opt("RunErrorsFatal", 0)

$USERNAME = "Admin"
$Password = "password"
$Domain = RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName")

select
   Case @OSVersion = "WIN_2000"
      Runasset ($username, $Domain, $password)
      $pid = Run(@SystemDir & "\Notepad.exe","",@SW_MINIMIZE )
      If $pid = 0 Then
         MsgBox(4096,"Error...","Please contact the help desk")
      Else
         ProcessClose($pid)
      EndIf
EndSelect
Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ok, i forgot the @OSVersion :idiot:

But my version could work aswell, right?

Please say it would work :lol:

Cause i really liked the idea with RunErrorsFatal since RunAsSet does not return any unsucceful value.

Instead of Case OSVersion

; Set the RunAs parameters to use local adminstrator account

$var1=RunAsSet("admin", @Computername, "adminpassword")

$var=AutoItSetOption ( "RunErrorsFatal", 0 )

; Check if OS is ok

If $var1 = 0 Then

MsgBox(0, "Error", "Your OS does not support automatic install" & @CRLF & "Please contact your Helpdesk")

Exit

EndIf

; Check if admin is ok

If $var = 1 Then

MsgBox(0, "Error", "Please contact Helpdesk")

Exit

EndIf

EDIT.. for the third time :D

I really dont see the idea to use Regread, to get the computername, when you can use @Computername?

Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I make a new reply cause all this gave me an idea :idiot:

I will create a GUI, where i can chose:

Username

Expire date

Software (A combo list with all software we got)

And a 2 button, Create and Cancel

When you start this GUI you enter the username of the person who gonna install the program, and also a expirede date. (This is to make the abuse to a minimum)

Then you chose a software for example Acrobat Write (license software)

After that you press create, then it will create a .exe file named AcrobatW.exe

You send the file to the user who gonna install the software, it will only work for that user and only until the expire date.

Cool idea :D

Edited by Doxie

Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I make a new reply cause all this gave me an idea :idiot:

I will create a GUI, where i can chose:

Username

Expire date

Software (A combo list with all software we got)

And a 2 button, Create and Cancel

When you start this GUI you enter the username of the person who gonna install the program, and also a expirede date. (This is to make the abuse to a minimum)

Then you chose a software for example Acrobat Write (license software)

After that you press create, then it will create a .exe file named AcrobatW.exe

You send the file to the user who gonna install the software, it will only work for that user and only until the expire date.

Cool idea :D

<{POST_SNAPBACK}>

I like that idea .... That is very cool

Edit: Now we need to figure out how to make the install run one time only then be useless if you try to install it again or on another computer ... now that would be way cool :lol:

Edited by psichosis

We have enough youth. How about a fountain of SMART?

Share this post


Link to post
Share on other sites

A combination of ideas did the trick. Thanks for the 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