jayshomp Posted March 22, 2008 Posted March 22, 2008 (edited) Hi all, I have another newb question for you all I'm simply trying to password protect a script so it isn't run by accident. I've gotten this far using the help file and some posts here: $pass = InputBox( "Password", "Please enter password", "", "*", 190, 115) If @Error Then Exit If $pass = "@reboot" Then MsgBox( 1, "Accepted", "Password accepted!", 30) Else MsgBox( 1, "Rejected!", "Incorrect Password", 5) EndIf What I'm looking for is 1) have the rest of the script not start and exit if at anytime "Cancel" is pressed and 2) if the password is incorrect have it loop back and ask for it again, and obviously 3) have the rest of the script start after a successful password and clicking "OK". Any help would be appreciated. Edited March 22, 2008 by jayshomp
Swift Posted March 22, 2008 Posted March 22, 2008 (edited) Global $Password="password";put your password here... $pass = InputBox( "Password", "Please enter password", "", "*", 190, 115) If @Error Then Exit If $pass = $Password Then MsgBox( 1, "Accepted", "Password accepted!", 30) Else MsgBox( 1, "Rejected!", "Incorrect Password", 5) EndIf ;Rest of script goes here.... Edited March 22, 2008 by Swift
jayshomp Posted March 22, 2008 Author Posted March 22, 2008 Global $Password="password";put your password here... $pass = InputBox( "Password", "Please enter password", "", "*", 190, 115) If @Error Then Exit If $pass = $Password Then MsgBox( 1, "Accepted", "Password accepted!", 30) Else MsgBox( 1, "Rejected!", "Incorrect Password", 5) EndIf ;Rest of script goes here....Thank you Swift but I'm still getting the same problem. The script still starts if clicking OK or Cancel in the Rejected box after an incorrect password is entered
McGod Posted March 22, 2008 Posted March 22, 2008 While 1 Global $pass = InputBox( "Password", "Please enter password", "", "*", 190, 115) If @error Then Exit If $pass = "@reboot" Then ExitLoop MsgBox( 1, "Rejected!", "Incorrect Password", 5) WEnd MsgBox( 1, "Accepted", "Password accepted!", 30) ;Script goes here [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u]
jayshomp Posted March 22, 2008 Author Posted March 22, 2008 While 1 Global $pass = InputBox( "Password", "Please enter password", "", "*", 190, 115) If @error Then Exit If $pass = "@reboot" Then ExitLoop MsgBox( 1, "Rejected!", "Incorrect Password", 5) WEnd MsgBox( 1, "Accepted", "Password accepted!", 30) ;Script goes hereThank you Chip, that's just about perfect. The last thing I need is for the script to exit if Cancel is pressed in the Accepted box. I thought "If @Error Then Exit" would work but apparently not The rest is exactly what I was looking for though, thank you again!
jayshomp Posted March 22, 2008 Author Posted March 22, 2008 Thank you Chip, that's just about perfect. The last thing I need is for the script to exit if Cancel is pressed in the Accepted box. I thought "If @Error Then Exit" would work but apparently not The rest is exactly what I was looking for though, thank you again!Nevermind I found it finally: If @error == 0 Then ExitThanks again!
Swift Posted March 22, 2008 Posted March 22, 2008 Heh, well sorry, I wasnt thinking when I wrote that, nor did I test it, but what he wrote should be what you need! Hope your script is a great one.
jayshomp Posted March 22, 2008 Author Posted March 22, 2008 Heh, well sorry, I wasnt thinking when I wrote that, nor did I test it, but what he wrote should be what you need! Hope your script is a great one.No apology necessary. I appreciate the effort and the quick response
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