Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How Do I Password Protect a Folder Using a Batch File?  (Read 8518 times)

0 Members and 1 Guest are viewing this topic.

green_burger

    Topic Starter


    Rookie

  • Ziggy boggy doog
    How Do I Password Protect a Folder Using a Batch File?
    « 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)

    yperron



      Rookie
      Re: How Do I Password Protect a Folder Using a Batch File?
      « Reply #1 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
      yp

      prashantbhavsar



        Rookie

        Re: How Do I Password Protect a Folder Using a Batch File?
        « Reply #2 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

        nictheman123



          Newbie

          • Experience: Familiar
          • OS: Windows XP
          Re: How Do I Password Protect a Folder Using a Batch File?
          « Reply #3 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