有没有办法在 windows 命令行中一次性使用 command/action?例如。输入许可证密钥
Is there a way to make a one time use command/action in a windows command line? eg. Inputting a license key
问题基本上在上面的标题。例如,我如何启用输入许可证密钥的一次性操作示例。
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%\System32\findstr.exe /LX "key=CoRrEcT KeY" >NUL || GoTo GetKey
:Start
Echo You entered the correct license key [%key%].
Pause
问题基本上在上面的标题。例如,我如何启用输入许可证密钥的一次性操作示例。
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%\System32\findstr.exe /LX "key=CoRrEcT KeY" >NUL || GoTo GetKey
:Start
Echo You entered the correct license key [%key%].
Pause