Batch file 如何去掉变量?(批)
我正在制作一个快速通过保护批处理(稍后将其设置为.exe),我希望在trys变量达到0时将其自身删除,但我不知道如何检查trys是否为0,或者如何从该变量中删除,快速示例:Batch file 如何去掉变量?(批),batch-file,variables,Batch File,Variables,我正在制作一个快速通过保护批处理(稍后将其设置为.exe),我希望在trys变量达到0时将其自身删除,但我不知道如何检查trys是否为0,或者如何从该变量中删除,快速示例: set %tries%=3 set /P c=Please Enter The Password; You Have %tries% Attempts Remaining if /I "%c%" EQU "Pass" goto :command_hub (insert a thing that checks if 0 an
set %tries%=3
set /P c=Please Enter The Password; You Have %tries% Attempts Remaining
if /I "%c%" EQU "Pass" goto :command_hub
(insert a thing that checks if 0 and then takes 1 if not)
goto :delete
:delete
(goto) 2>nul & del "%~f0"
应该是
set /a tries=3
:retry
set /P c=Please Enter The Password; You Have %tries% Attempts Remaining
if /I "%c%" EQU "Pass" goto command_hub
set /a tries-=1
if %tries% gtr 0 goto retry
设置%tries%
将设置一个名为tries的当前内容的变量
set/a执行算术运算。当指定像3
这样的数值时,它是可选的
请参见提示文档中的set/?
goto:label
命令有效,但不需要冒号,除非在goto:eof
的特定情况下,这意味着“转到文件末尾”(终止例程)。标签:eof
已被理解,不应编程。键入设置/?
并读取输出。请特别注意/a
开关。在SET
命令的帮助文件中,它实际上讨论了/a
在/P
使用之前的用法。不知道你是怎么错过的。s/leq/geq/
:)@rojo s/leq/gtr/!巴纳纳塔克斯,伙计!学到的比我今天想象的还要多:)
set /a tries=3
:retry
set /P c=Please Enter The Password; You Have %tries% Attempts Remaining
if /I "%c%" EQU "Pass" goto command_hub
set /a tries-=1
if %tries% gtr 0 goto retry