有没有办法在windows命令行中执行一次性使用命令/操作?例如,输入许可证密钥



问题基本上在上面的标题中。例如,我如何启用一次性操作示例输入许可证密钥。

set /p key= "Please input your license key: "
IF [%key%]= [something] goto :start
IF [%key%]= [anything] goto :start

有没有一种方法可以让上面的代码只在第一次使用时弹出?如果他们输入了错误的键,就会一直保持这种状态,直到他们输入正确的键。

最常见的方法是使用一个简单的GoTo循环:

:GetKey
ClS
Set /P "key=Please input your license key: "
Set "key=%key:"=%"
(Set key) 2>NUL | %SystemRoot%System32findstr.exe /LX "key=CoRrEcT KeY" >NUL || GoTo GetKey
:Start
Echo You entered the correct license key [%key%].
Pause

相关内容

最新更新