Jump to content

Recommended Posts

Posted (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 by jayshomp
Posted (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 by Swift
Posted

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 :)
Posted

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

Posted

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
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!

Posted

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 Exit

Thanks again!

Posted

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.

Posted

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 :)

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