Question

Here is my batch file I'm attempting to construct (with asterisks where my product key goes) that checks if windows is activated and if not activates it. It seems to get stuck on the end of the IF statment, and breaks as soon as it hits the end of the line at "(". Any thoughts? The pauses are there for error checking

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
) 
Was it helpful?

Solution

I tried your code and simply adding quotes around %xprvar% made it work:

IF "%xprvar%" == "    The machine is permanently activated." (
....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top