【问题标题】:Getting stuck on if then syntax for a batch file陷入批处理文件的 if then 语法
【发布时间】:2014-04-14 08:22:53
【问题描述】:

这是我正在尝试构建的批处理文件(在我的产品密钥所在的位置带有星号),用于检查 Windows 是否已激活,如果没有则激活它。它似乎卡在 IF 语句的末尾,并在“(”处到达行尾时立即中断。有什么想法吗?暂停是为了检查错误

echo Welcome to the Br1llaintJim Windows 7 activator. A dialogue box
echo should appear at the end if the activation is successful.
echo.
echo Press any key to proceed with activation...
pause > nul
cscript %windir%\system32\slmgr.vbs /xpr > xprtest.txt
pause
for /F "skip=4 delims=" %%i in (xprtest.txt) do set "xprvar=%%i"&goto nextline
:nextline
pause
IF %xprvar% == "    The machine is permanently activated." (
echo System is already activated. Exiting now...
pause 
exit
) ELSE (
slmgr /ipk *****-*****-*****-*****-*****
pause
slmgr /ato
echo System has been successfully activated
pause
) 

【问题讨论】:

  • 你试过IF "%xprvar%" == " The machine is permanently activated."吗?

标签: batch-file if-statement activation


【解决方案1】:

我尝试了您的代码,只需在 %xprvar% 周围添加引号就可以了:

IF "%xprvar%" == "    The machine is permanently activated." (
....

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-14
    • 2022-01-11
    • 2017-08-01
    • 2021-06-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多