.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.
batch-file cmd
New contributor
|
show 4 more comments
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.
batch-file cmd
New contributor
You could replace lines6
-14
inclusive with these two lines,Choice /M "Are you sure you want to lock the folder"
andIf ErrorLevel 2 GoTo End
– Compo
Nov 21 at 21:43
You could replace lines21
-23
inclusive with these three lines,Set "pass="
,Set /P "pass=Enter the password to unlock the folder: "
andIf /I Not "%pass%"=="pass123" GoTo FAIL
.
– Compo
Nov 21 at 21:53
Do you mean you want to change the passwordpass123
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
|
show 4 more comments
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.
batch-file cmd
New contributor
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
batch-file cmd
New contributor
New contributor
edited Nov 22 at 9:01
Armali
6,88593696
6,88593696
New contributor
asked Nov 21 at 21:17
Mr.exe
1
1
New contributor
New contributor
You could replace lines6
-14
inclusive with these two lines,Choice /M "Are you sure you want to lock the folder"
andIf ErrorLevel 2 GoTo End
– Compo
Nov 21 at 21:43
You could replace lines21
-23
inclusive with these three lines,Set "pass="
,Set /P "pass=Enter the password to unlock the folder: "
andIf /I Not "%pass%"=="pass123" GoTo FAIL
.
– Compo
Nov 21 at 21:53
Do you mean you want to change the passwordpass123
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
|
show 4 more comments
You could replace lines6
-14
inclusive with these two lines,Choice /M "Are you sure you want to lock the folder"
andIf ErrorLevel 2 GoTo End
– Compo
Nov 21 at 21:43
You could replace lines21
-23
inclusive with these three lines,Set "pass="
,Set /P "pass=Enter the password to unlock the folder: "
andIf /I Not "%pass%"=="pass123" GoTo FAIL
.
– Compo
Nov 21 at 21:53
Do you mean you want to change the passwordpass123
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
|
show 4 more comments
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 22 at 11:41
Gerhard Barnard
6,77931131
6,77931131
add a comment |
add a comment |
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.
Mr.exe is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
You could replace lines
6
-14
inclusive with these two lines,Choice /M "Are you sure you want to lock the folder"
andIf 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: "
andIf /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