Password protect on batch [TUT]

View previous topic View next topic Go down

Password protect on batch [TUT]

Post by Logic_Bomb on Tue May 12, 2009 8:40 pm

Batch password protection.
Use this at the top off all of your Batch Codes to keep them safe (As long as you compile them to Exe so that they can't just view the source.)

Code:

@echo off
:start
cls
Set Pass= pass
Set /P Userpass= What is the password:
IF %Userpass% == %Pass% Goto Passed
IF '%Userpass%' == '*' goto nopass
:nopass
echo Sorry wrong password
Pause > NUL
goto start
:passed
Echo Success, Right pass!
pause > NUL
goto start

I used markers just as I did in the last TUT by me, But this time I introduced variables, these can be used by user input or can be pre-defined. Think of it just like algebra.

'Set hello= Wow' (would mean it has now set the variable %hello% to equal "Wow")

'Set /a hello= 1' (would mean it has now set the variable %hello% to equal 1 and the /a defines it as a mathmatical variable)

'Set /p hello= what do you say to people when you meet them?' (would mean it has now set the variable %hello% anything the user enters to the question "what do you say to people when you meet them" )

I then used 'IF' to make a decision based on weather the variable was equal to another variable, In this case if the user input was equal to 'pass' (Case sensitive) then it would send you to the passed marker if it was not equal to 'pass' then it would send you too the nopass marker.

That concludes this tutorial, check out my other posts for more Batch tut's

Kieron xD


Last edited by Admin on Mon May 18, 2009 7:30 pm; edited 1 time in total
avatar
Logic_Bomb
Admin
Admin

Posts : 161
Join date : 2009-05-12
Age : 25
Location : Cyberspace

View user profile http://the-underground.darkbb.com

Back to top Go down

REP++

Post by Oliver on Mon May 18, 2009 7:11 pm

Very useful for keeping private files secure.
Maybe you could put the result in another Batch tutorial that when the password's incorrect it deletes the file?
Nice tutorial.

REP++
-Oliver.

Oliver
Admin
Admin

Posts : 8
Join date : 2009-05-14
Age : 23

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum