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如何从cmd而不是从代码中更改密码?在这里我真的需要你的帮助,因为我不想每次当我想要更改密码时,我需要打开它的txt。
发布于 2018-11-22 19:41:33
我根本不会关注你的代码,我只会演示你问的主要问题,那就是“如何通过脚本更改密码”。
正在将密码写入文件方法:
@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
)如您所见,我们创建一个新密码,对其进行验证,然后将其写入密码文件。如果该文件不存在,我们只需执行完全相同的操作。
:checkpass标签演示了如何使用文件中的密码。所以在你当前使用if NOT %pass%== pass123 goto FAIL的地方,我们使用循环来读取文件。
https://stackoverflow.com/questions/53420593
复制相似问题