:deleteaccount
cls
echo what account do you want to delete?
set /p dan=
if not exist %~dp0\database\%dan%\ (
echo this account doesn't exist & pause >nul & goto stage
)
else %~dp0\database\%dan%\ (
cls & echo password:
set /p dap=
call %~dp0\database\%dan%\%dan%.bat
if %dap% == %rpassword1% (
echo are you sure you want to delete this account? yes/no
set /p daq=
if %daq% == yes (
@RD /S /Q %~dp0\database\%daq%\
echo account succesfully deleted
pause >nul & goto stage)
if %daq% == no (goto stage)
)
)
为要删除的帐户输入正确的密码后,出于某种原因,它会显示< is unexpected
。
答案 0 :(得分:0)
为了节省屏幕空间,下面是您的脚本示例,已对其进行了修改,以使用正确的语法并包含逻辑结构。
@Echo Off
:DeleteAccount
ClS
Set "dan=:"
Set /P "dan=Which account do you want to remove? "
If Not Exist "%~dp0database\%dan%\" (
Echo The account does not exist.
"%__AppDir__%timeout.exe" /T 3 /NoBreak 1> NUL
GoTo Stage
)
ClS
If Not Exist "%~dp0database\%dan%\%dan%.bat" (
Echo The required batch file is missing for the account.
"%__AppDir__%timeout.exe" /T 3 /NoBreak 1> NUL
GoTo Stage
)
Set "dap="
Set /P "dap=Please enter your password: "
Call "%~dp0database\%dan%\%dan%.bat" 2> NUL
If ErrorLevel 1 (
Echo A error occurred running the batch file.
"%__AppDir__%timeout.exe" /T 3 /NoBreak 1> NUL
GoTo Stage
)
If "%dap%." == "%rpassword1%." (
"%__AppDir__%choice.exe" /M "Are you sure you want to remove this account"
If Not ErrorLevel 2 (
RD /S /Q "%~dp0database\%daq%" 2> NUL
If ErrorLevel 1 (
Echo An error occurred deleting the account.
) Else Echo Account successfully removed.
"%__AppDir__%timeout.exe" /T 3 /NoBreak 1> NUL
)
) Else (
Echo Incorrect password.
"%__AppDir__%timeout.exe" /T 3 /NoBreak 1> NUL
)
:Stage
Rem Rest of code goes here.
请仔细阅读并仔细阅读它,并特别注意所包含的双引号,该双引号用于将字符串括起来并保护特殊字符。 包括前两行和后两行是为了使本示例保持独立(因为您发布的摘录中省略了它们)。