Guest NU2Autoit Posted December 15, 2004 Share Posted December 15, 2004 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", "") Link to comment Share on other sites More sharing options...
Doxie Posted December 15, 2004 Share Posted December 15, 2004 (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 December 15, 2004 by Doxie Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
CyberSlug Posted December 15, 2004 Share Posted December 15, 2004 (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 December 15, 2004 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! Link to comment Share on other sites More sharing options...
Doxie Posted December 15, 2004 Share Posted December 15, 2004 (edited) Ok, i forgot the @OSVersion But my version could work aswell, right?Please say it would work 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") ExitEndIf; Check if admin is ok If $var = 1 Then MsgBox(0, "Error", "Please contact Helpdesk") ExitEndIfEDIT.. for the third time I really dont see the idea to use Regread, to get the computername, when you can use @Computername? Edited December 15, 2004 by Doxie Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
Doxie Posted December 15, 2004 Share Posted December 15, 2004 (edited) I make a new reply cause all this gave me an idea 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 Edited December 15, 2004 by Doxie Were ever i lay my script is my home... Link to comment Share on other sites More sharing options...
sykes Posted December 15, 2004 Share Posted December 15, 2004 (edited) I make a new reply cause all this gave me an idea I will create a GUI, where i can chose:UsernameExpire dateSoftware (A combo list with all software we got)And a 2 button, Create and CancelWhen 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.exeYou 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 <{POST_SNAPBACK}>I like that idea .... That is very coolEdit: 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 Edited December 15, 2004 by psichosis We have enough youth. How about a fountain of SMART? Link to comment Share on other sites More sharing options...
Guest NU2Autoit Posted December 15, 2004 Share Posted December 15, 2004 A combination of ideas did the trick. Thanks for the help!!!! 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