Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何去掉变量?(批)_Batch File_Variables - Fatal编程技术网

Batch file 如何去掉变量?(批)

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

我正在制作一个快速通过保护批处理(稍后将其设置为.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 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