我想知道我的代码是否能够在激活 Windows 后无需交互单击“确定”即可一个接一个地运行命令,或者我应该在每个命令行上添加“Start /wait cmd”......之类的命令。
@echo off
REM Windows Activation
Echo Activate Windows
set /p key="Input Windows Key : "
slmgr /ipk %key% /ato && ^
wmic csproduct && ^
gpupdate /force
Modified
@echo off
REM Windows Activation
Echo Activate Windows
echo. =================================
set /p key="Input Windows KEY : "
echo. =================================
cscript %windir%\system32\slmgr.vbs /ato | find /i "successfully" && (goto status)
:status
Echo Check Windows Status
SetLocal EnableExtensions EnableDelayedExpansion
Set "WinVerAct="
For /f "tokens=*" %%W in ('
cscript /Nologo "C:\Windows\System32\slmgr.vbs" /xpr
') Do Set "WinVerAct=!WinVerAct! %%W"
if Not defined WinVerAct (
Echo:No response from slmgr.vbs
Exit /B 1
Echo Windows Version Activation Status:
Echo:"%WinVerAct:~1%"
wmic csproduct && ^
gpupdate /force
@exit /b
答案1
为了避免弹出窗口,请使用cscript
运行 slmgr.vbs 脚本。
cscript %windir%\system32\slmgr.vbs /ato