.bat folder lock: how to change password inside Cmd











up vote
0
down vote

favorite












    cls
@ECHO OFF
title Folder posnetki
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST posnetki goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren posnetki "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%== pass123 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" posnetki
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md posnetki
echo posnetki created successfully
goto End
:End


How to make password change from cmd not from code? Here I really need your help because I dont want everytime when I want to change password I need to open it by txt.










share|improve this question









New contributor




Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You could replace lines 6-14 inclusive with these two lines, Choice /M "Are you sure you want to lock the folder" and If ErrorLevel 2 GoTo End
    – Compo
    Nov 21 at 21:43










  • You could replace lines 21-23 inclusive with these three lines, Set "pass=", Set /P "pass=Enter the password to unlock the folder: " and If /I Not "%pass%"=="pass123" GoTo FAIL.
    – Compo
    Nov 21 at 21:53












  • Do you mean you want to change the password pass123 inline inside of the script by using it while batch is running?
    – Gerhard Barnard
    Nov 22 at 6:05










  • yeah bro i want to change it inside of script
    – Mr.exe
    Nov 22 at 8:27










  • why not just save it in different file, then set an option to either read it or change it.. much simpler than in the same file. If you respond, please use the @GerhardBarnard so I get notified of your response.
    – Gerhard Barnard
    Nov 22 at 9:56















up vote
0
down vote

favorite












    cls
@ECHO OFF
title Folder posnetki
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST posnetki goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren posnetki "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%== pass123 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" posnetki
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md posnetki
echo posnetki created successfully
goto End
:End


How to make password change from cmd not from code? Here I really need your help because I dont want everytime when I want to change password I need to open it by txt.










share|improve this question









New contributor




Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You could replace lines 6-14 inclusive with these two lines, Choice /M "Are you sure you want to lock the folder" and If ErrorLevel 2 GoTo End
    – Compo
    Nov 21 at 21:43










  • You could replace lines 21-23 inclusive with these three lines, Set "pass=", Set /P "pass=Enter the password to unlock the folder: " and If /I Not "%pass%"=="pass123" GoTo FAIL.
    – Compo
    Nov 21 at 21:53












  • Do you mean you want to change the password pass123 inline inside of the script by using it while batch is running?
    – Gerhard Barnard
    Nov 22 at 6:05










  • yeah bro i want to change it inside of script
    – Mr.exe
    Nov 22 at 8:27










  • why not just save it in different file, then set an option to either read it or change it.. much simpler than in the same file. If you respond, please use the @GerhardBarnard so I get notified of your response.
    – Gerhard Barnard
    Nov 22 at 9:56













up vote
0
down vote

favorite









up vote
0
down vote

favorite











    cls
@ECHO OFF
title Folder posnetki
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST posnetki goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren posnetki "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%== pass123 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" posnetki
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md posnetki
echo posnetki created successfully
goto End
:End


How to make password change from cmd not from code? Here I really need your help because I dont want everytime when I want to change password I need to open it by txt.










share|improve this question









New contributor




Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











    cls
@ECHO OFF
title Folder posnetki
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST posnetki goto MDLOCKER
:CONFIRM
echo Are you sure you want to lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren posnetki "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%== pass123 goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" posnetki
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md posnetki
echo posnetki created successfully
goto End
:End


How to make password change from cmd not from code? Here I really need your help because I dont want everytime when I want to change password I need to open it by txt.







batch-file cmd






share|improve this question









New contributor




Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 22 at 9:01









Armali

6,88593696




6,88593696






New contributor




Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 21 at 21:17









Mr.exe

1




1




New contributor




Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Mr.exe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • You could replace lines 6-14 inclusive with these two lines, Choice /M "Are you sure you want to lock the folder" and If ErrorLevel 2 GoTo End
    – Compo
    Nov 21 at 21:43










  • You could replace lines 21-23 inclusive with these three lines, Set "pass=", Set /P "pass=Enter the password to unlock the folder: " and If /I Not "%pass%"=="pass123" GoTo FAIL.
    – Compo
    Nov 21 at 21:53












  • Do you mean you want to change the password pass123 inline inside of the script by using it while batch is running?
    – Gerhard Barnard
    Nov 22 at 6:05










  • yeah bro i want to change it inside of script
    – Mr.exe
    Nov 22 at 8:27










  • why not just save it in different file, then set an option to either read it or change it.. much simpler than in the same file. If you respond, please use the @GerhardBarnard so I get notified of your response.
    – Gerhard Barnard
    Nov 22 at 9:56


















  • You could replace lines 6-14 inclusive with these two lines, Choice /M "Are you sure you want to lock the folder" and If ErrorLevel 2 GoTo End
    – Compo
    Nov 21 at 21:43










  • You could replace lines 21-23 inclusive with these three lines, Set "pass=", Set /P "pass=Enter the password to unlock the folder: " and If /I Not "%pass%"=="pass123" GoTo FAIL.
    – Compo
    Nov 21 at 21:53












  • Do you mean you want to change the password pass123 inline inside of the script by using it while batch is running?
    – Gerhard Barnard
    Nov 22 at 6:05










  • yeah bro i want to change it inside of script
    – Mr.exe
    Nov 22 at 8:27










  • why not just save it in different file, then set an option to either read it or change it.. much simpler than in the same file. If you respond, please use the @GerhardBarnard so I get notified of your response.
    – Gerhard Barnard
    Nov 22 at 9:56
















You could replace lines 6-14 inclusive with these two lines, Choice /M "Are you sure you want to lock the folder" and If ErrorLevel 2 GoTo End
– Compo
Nov 21 at 21:43




You could replace lines 6-14 inclusive with these two lines, Choice /M "Are you sure you want to lock the folder" and If ErrorLevel 2 GoTo End
– Compo
Nov 21 at 21:43












You could replace lines 21-23 inclusive with these three lines, Set "pass=", Set /P "pass=Enter the password to unlock the folder: " and If /I Not "%pass%"=="pass123" GoTo FAIL.
– Compo
Nov 21 at 21:53






You could replace lines 21-23 inclusive with these three lines, Set "pass=", Set /P "pass=Enter the password to unlock the folder: " and If /I Not "%pass%"=="pass123" GoTo FAIL.
– Compo
Nov 21 at 21:53














Do you mean you want to change the password pass123 inline inside of the script by using it while batch is running?
– Gerhard Barnard
Nov 22 at 6:05




Do you mean you want to change the password pass123 inline inside of the script by using it while batch is running?
– Gerhard Barnard
Nov 22 at 6:05












yeah bro i want to change it inside of script
– Mr.exe
Nov 22 at 8:27




yeah bro i want to change it inside of script
– Mr.exe
Nov 22 at 8:27












why not just save it in different file, then set an option to either read it or change it.. much simpler than in the same file. If you respond, please use the @GerhardBarnard so I get notified of your response.
– Gerhard Barnard
Nov 22 at 9:56




why not just save it in different file, then set an option to either read it or change it.. much simpler than in the same file. If you respond, please use the @GerhardBarnard so I get notified of your response.
– Gerhard Barnard
Nov 22 at 9:56












1 Answer
1






active

oldest

votes

















up vote
0
down vote













I am not going to focus on your code at all, I am simply going to demonstrate what you asked as the main question, that being "how to change password via script".



Writing password to a file method:



@echo off
cls
:start
if not exist "%temp%tmppwd.lck" (
echo password file does not yet exist Please create a Password.
goto chpwd
)
Choice /C TC /M "Select U to unlock T to test password"
if %errorlevel%==2 goto chpwd
if %errorlevel%==1 goto checkpass

:chpwd
set /p "passwd=Enter your new password and press Enter: "
set /p "passwdc=Confirm new password: "
if "%passwd%"=="%passwdc%" (
echo %passwd% > %temp%tmppwd.lck
goto start
) else (
cls
echo Sorry, Passwords did not match, please retry
goto chpwd
)
:checkpass
for /f %%i in ('type "%temp%tmppwd.lck"') do set "test=%%i"
set /p "attempt=Enter password to see if this works: "
if "%attempt%"=="%test%" (
echo Passwords Match & pause
) else (
echo Sorry, you entered the incorrect password
)


So as you can see, we create a new password, verify it and then write it to a password file. If the file does not exist, we simply do the exact same.



The :checkpass label demonstrates how you can use the password from the file. So where you currently use if NOT %pass%== pass123 goto FAIL we use the loop to read from file.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Mr.exe is a new contributor. Be nice, and check out our Code of Conduct.










     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420593%2fbat-folder-lock-how-to-change-password-inside-cmd%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I am not going to focus on your code at all, I am simply going to demonstrate what you asked as the main question, that being "how to change password via script".



    Writing password to a file method:



    @echo off
    cls
    :start
    if not exist "%temp%tmppwd.lck" (
    echo password file does not yet exist Please create a Password.
    goto chpwd
    )
    Choice /C TC /M "Select U to unlock T to test password"
    if %errorlevel%==2 goto chpwd
    if %errorlevel%==1 goto checkpass

    :chpwd
    set /p "passwd=Enter your new password and press Enter: "
    set /p "passwdc=Confirm new password: "
    if "%passwd%"=="%passwdc%" (
    echo %passwd% > %temp%tmppwd.lck
    goto start
    ) else (
    cls
    echo Sorry, Passwords did not match, please retry
    goto chpwd
    )
    :checkpass
    for /f %%i in ('type "%temp%tmppwd.lck"') do set "test=%%i"
    set /p "attempt=Enter password to see if this works: "
    if "%attempt%"=="%test%" (
    echo Passwords Match & pause
    ) else (
    echo Sorry, you entered the incorrect password
    )


    So as you can see, we create a new password, verify it and then write it to a password file. If the file does not exist, we simply do the exact same.



    The :checkpass label demonstrates how you can use the password from the file. So where you currently use if NOT %pass%== pass123 goto FAIL we use the loop to read from file.






    share|improve this answer

























      up vote
      0
      down vote













      I am not going to focus on your code at all, I am simply going to demonstrate what you asked as the main question, that being "how to change password via script".



      Writing password to a file method:



      @echo off
      cls
      :start
      if not exist "%temp%tmppwd.lck" (
      echo password file does not yet exist Please create a Password.
      goto chpwd
      )
      Choice /C TC /M "Select U to unlock T to test password"
      if %errorlevel%==2 goto chpwd
      if %errorlevel%==1 goto checkpass

      :chpwd
      set /p "passwd=Enter your new password and press Enter: "
      set /p "passwdc=Confirm new password: "
      if "%passwd%"=="%passwdc%" (
      echo %passwd% > %temp%tmppwd.lck
      goto start
      ) else (
      cls
      echo Sorry, Passwords did not match, please retry
      goto chpwd
      )
      :checkpass
      for /f %%i in ('type "%temp%tmppwd.lck"') do set "test=%%i"
      set /p "attempt=Enter password to see if this works: "
      if "%attempt%"=="%test%" (
      echo Passwords Match & pause
      ) else (
      echo Sorry, you entered the incorrect password
      )


      So as you can see, we create a new password, verify it and then write it to a password file. If the file does not exist, we simply do the exact same.



      The :checkpass label demonstrates how you can use the password from the file. So where you currently use if NOT %pass%== pass123 goto FAIL we use the loop to read from file.






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I am not going to focus on your code at all, I am simply going to demonstrate what you asked as the main question, that being "how to change password via script".



        Writing password to a file method:



        @echo off
        cls
        :start
        if not exist "%temp%tmppwd.lck" (
        echo password file does not yet exist Please create a Password.
        goto chpwd
        )
        Choice /C TC /M "Select U to unlock T to test password"
        if %errorlevel%==2 goto chpwd
        if %errorlevel%==1 goto checkpass

        :chpwd
        set /p "passwd=Enter your new password and press Enter: "
        set /p "passwdc=Confirm new password: "
        if "%passwd%"=="%passwdc%" (
        echo %passwd% > %temp%tmppwd.lck
        goto start
        ) else (
        cls
        echo Sorry, Passwords did not match, please retry
        goto chpwd
        )
        :checkpass
        for /f %%i in ('type "%temp%tmppwd.lck"') do set "test=%%i"
        set /p "attempt=Enter password to see if this works: "
        if "%attempt%"=="%test%" (
        echo Passwords Match & pause
        ) else (
        echo Sorry, you entered the incorrect password
        )


        So as you can see, we create a new password, verify it and then write it to a password file. If the file does not exist, we simply do the exact same.



        The :checkpass label demonstrates how you can use the password from the file. So where you currently use if NOT %pass%== pass123 goto FAIL we use the loop to read from file.






        share|improve this answer












        I am not going to focus on your code at all, I am simply going to demonstrate what you asked as the main question, that being "how to change password via script".



        Writing password to a file method:



        @echo off
        cls
        :start
        if not exist "%temp%tmppwd.lck" (
        echo password file does not yet exist Please create a Password.
        goto chpwd
        )
        Choice /C TC /M "Select U to unlock T to test password"
        if %errorlevel%==2 goto chpwd
        if %errorlevel%==1 goto checkpass

        :chpwd
        set /p "passwd=Enter your new password and press Enter: "
        set /p "passwdc=Confirm new password: "
        if "%passwd%"=="%passwdc%" (
        echo %passwd% > %temp%tmppwd.lck
        goto start
        ) else (
        cls
        echo Sorry, Passwords did not match, please retry
        goto chpwd
        )
        :checkpass
        for /f %%i in ('type "%temp%tmppwd.lck"') do set "test=%%i"
        set /p "attempt=Enter password to see if this works: "
        if "%attempt%"=="%test%" (
        echo Passwords Match & pause
        ) else (
        echo Sorry, you entered the incorrect password
        )


        So as you can see, we create a new password, verify it and then write it to a password file. If the file does not exist, we simply do the exact same.



        The :checkpass label demonstrates how you can use the password from the file. So where you currently use if NOT %pass%== pass123 goto FAIL we use the loop to read from file.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 11:41









        Gerhard Barnard

        6,77931131




        6,77931131






















            Mr.exe is a new contributor. Be nice, and check out our Code of Conduct.










             

            draft saved


            draft discarded


















            Mr.exe is a new contributor. Be nice, and check out our Code of Conduct.













            Mr.exe is a new contributor. Be nice, and check out our Code of Conduct.












            Mr.exe is a new contributor. Be nice, and check out our Code of Conduct.















             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53420593%2fbat-folder-lock-how-to-change-password-inside-cmd%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            What visual should I use to simply compare current year value vs last year in Power BI desktop

            Alexandru Averescu

            Trompette piccolo