文件名:1.bat
@echo off
cls
set /a a=%~n0+1
set /a b=%~n0*2
For /l %%c in (%a%,1,%b%) do type %~nx0 > %%c.bat
cls
echo Enter password:
set /p "Pass=>"
If not %pass%==tamaulipas_living_rock_cactus (
goto fail
)
exit /b
:fail
echo WRONG!
pause
For /f %%d in ('dir /a /b /on') do set f=%%d
call %f%
这个程序应该在它所在的任何文件夹中制作一堆自己的副本,每次该密码输入错误时加倍。在测试时,程序进入16,然后是18并停止。如果它停在32或16那将会有一定意义,因为它是2的幂,也许某事正在限制它,但为什么18,这样一个随机数,停止点?而奇怪的是,运行18.bat做了它应该做的事情,和36和72等一样。部分说:
For /f %%d in ('dir /a /b /on') do set f=%%d
call %f%
应运行18.bat,但它只是刷新密码提示而不创建任何新文件。
我想和我的朋友(电脑坏了)弄乱,最后告诉他密码是512或者其他什么。
或者,我尝试删除密码部分并将其替换为
@echo off
cls
If %~n0==512 (
Exit /b
)
set /a a=%~n0+1
set /a b=%~n0*2
For /l %%c in (%a%,1,%b%) do type %~nx0 > %%c.bat
For /f %%d in ('dir /a /b /on') do set f=%%d
call %f%
但是这个有着同样奇怪的结果
答案 0 :(得分:1)
By changing :
If %~n0==512 (
Exit /b
)
to:
If %~n0==8 (
Exit /b
)
it worked correctly, but not for:
If %~n0==16 (
Exit /b
)
And then I realized the program looks for them sorted in name order, and the first digit is the first one that is processed, so the program would repeat 9.bat over and over again, which is why it ends at 18.
Sorting by date (which I originally didn't do in fear of the computer not being accurate to the nanosecond) fixed the problem