Computer Hope

Microsoft => Microsoft DOS => Topic started by: green_burger on November 16, 2007, 07:36:01 AM

Title: How Do I Password Protect a Folder Using a Batch File?
Post by: green_burger on November 16, 2007, 07:36:01 AM
I need to protect a folder using a batch file
Using this command line:

@echo off
cls
echo Please enter a password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
:deny
echo.
echo.
echo Access Denied 
echo Please enter password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
goto deny
:accessgranted
cls
echo Access Granted.
pause
exit

I need it so that when the folder is double-clicked on, the batch file opens up, blocking entry to the  folder until the correct password is entered.
Thanks in advance.

P.S: The password for the batch command line is 'password' (minus the inverted commas)
Title: Re: How Do I Password Protect a Folder Using a Batch File?
Post by: yperron on November 16, 2007, 08:54:54 AM
I did post a question on password a few weeks ago
http://www.computerhope.com/forum/index.php/topic,45132.0.html
maybe you could find there some useful information for your problem.

cheers
yp
Title: Re: How Do I Password Protect a Folder Using a Batch File?
Post by: prashantbhavsar on November 16, 2007, 10:37:50 AM
I need to protect a folder using a batch file
Using this command line:

@echo off
cls
echo Please enter a password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
:deny
echo.
echo.
echo Access Denied 
echo Please enter password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
goto deny
:accessgranted
cls
echo Access Granted.
pause
exit

I need it so that when the folder is double-clicked on, the batch file opens up, blocking entry to the  folder until the correct password is entered.
Thanks in advance.

P.S: The password for the batch command line is 'password' (minus the inverted commas)
I need to protect a folder using a batch file
Using this command line:

@echo off
cls
echo Please enter a password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
:deny
echo.
echo.
echo Access Denied 
echo Please enter password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
goto deny
:accessgranted
cls
echo Access Granted.
pause
exit

I need it so that when the folder is double-clicked on, the batch file opens up, blocking entry to the  folder until the correct password is entered.
Thanks in advance.

P.S: The password for the batch command line is 'password' (minus the inverted commas)
when i double click the batch file, it doesn,t open. can u tell me how can i access the locked folder
Title: Re: How Do I Password Protect a Folder Using a Batch File?
Post by: nictheman123 on March 03, 2013, 09:48:14 AM
Hey i tried this out and this is actually pretty cool. Admiration aside there is a simple solution to your program. Simply name the bat file the same as the program you want to access then hide the file somewhere then add this to your code after pause:
cd "yourpath"
start "yourfilename"

Substitute "yourpath" with the path where the file is hidden and substitute "yourfilename" with the name of your file. I tried this
opening a bat file i wrote under a custom directory and the code was as follows after a bit of editing

@echo off
cls
echo Please enter a password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
:deny
echo.
echo.
echo Access Denied 
echo Please enter password to continue:
set /p inputchoice=
IF %inputchoice% equ password goto accessgranted
goto deny
:accessgranted
cls
echo Access Granted.
pause
cd c:\mybacth
start helloworld.bat
exit
try this out and see how it works