Jump to content



Photo

Script password protection help


  • Please log in to reply
7 replies to this topic

#1 jayshomp

jayshomp

    Seeker

  • Active Members
  • 11 posts

Posted 22 March 2008 - 12:09 AM

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, 22 March 2008 - 12:10 AM.








#2 Swift

Swift

    Get Linux Ubuntu Now.

  • Banned (NOT IN USE)
  • 1,706 posts

Posted 22 March 2008 - 12:17 AM

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, 22 March 2008 - 12:18 AM.


#3 jayshomp

jayshomp

    Seeker

  • Active Members
  • 11 posts

Posted 22 March 2008 - 12:29 AM

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

#4 McGod

McGod

    Formerly Chip

  • Active Members
  • PipPipPipPipPipPip
  • 589 posts

Posted 22 March 2008 - 12:29 AM

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


#5 jayshomp

jayshomp

    Seeker

  • Active Members
  • 11 posts

Posted 22 March 2008 - 12:52 AM

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!

#6 jayshomp

jayshomp

    Seeker

  • Active Members
  • 11 posts

Posted 22 March 2008 - 01:01 AM

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!

#7 Swift

Swift

    Get Linux Ubuntu Now.

  • Banned (NOT IN USE)
  • 1,706 posts

Posted 22 March 2008 - 01:07 AM

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.

#8 jayshomp

jayshomp

    Seeker

  • Active Members
  • 11 posts

Posted 22 March 2008 - 01:42 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users