尝试创建一个锁定系统

尝试创建一个锁定系统

我一直在尝试创建一个锁定系统,只是为了加深我对批处理文件的理解。说清楚一点,这不应该非常复杂,甚至不实用。这只是我一直想学习如何创建的东西。当然,如果我需要一个真正的额外密码系统,我可以在网上找到一个程序。如果你只是在这里说我可以在网上找到一个,相信我,我知道。如前所述,我只是想学习如何让它工作。

理论上,它应该在启动时运行,然后要求输入密码才能继续。如果 10 秒内没有输入密码,系统就会重新启动。如果密码不正确或窗口已关闭,系统应该重新启动。我昨晚才开始使用批处理,这是我第一次深入的编码体验,这让我非常困惑。

我本来打算让它打开另一个批处理文件,不断询问另一个窗口是否打开,反之亦然,但我找不到在批处理程序之间发送命令的方法。我遇到的最大问题是我无法让倒计时(从 10 开始)允许输入。这是我目前所拥有的,很抱歉我在这方面很糟糕(出于测试原因,我删除了重新启动命令):

    @echo off
    color 02 
    title DPS
    echo Input the correct password before you continue, please. 
    set/p input=
    if %input%==prot goto end
    goto wrong
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 10 -Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 9 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 8 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 7 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 6 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 5 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 4 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 3 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 2 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 1 - Input the correct password before you continue, please.
    ping 192.0.2.2 -n 1 -w 1000 > nul
    cls
    echo 0
    echo (restart script here)
    :end
    echo Welcome back.
    pause
    exit
    :wrong 
    echo (restart script here)
    pause 

相关内容