Search code examples
batch-filewindows-scripting

batch file scripting - Windows 7 Non-Volume License Activation


I'm trying to create a batch file for Activating Windows after cloning for individual pc license (not Volume License) but it seems not working. This will help a lot for tech support to speed up the process. Can someone help me figure out the problem please? My script below:

@ECHO OFF

pause

:WinActivation
SET WIN7Act=
CLS
ECHO.
ECHO.
ECHO ------------------------------------
ECHO - Activate Windows 7 Non-VL... -
ECHO ------------------------------------
slmgr.vbs -ipk SET /P WIN7Act=Input PRODUCT KEY and press [ENTER] (X to exit):
IF NOT DEFINED WIN7Act GOTO WinActivation
CALL :TR %WIN7Act% WIN7Act

:END
IF /I "%WIN7Act%"=="X" GOTO ENDED

:ENDED
EXIT /B

:TR
SET %2=%1
GOTO ACT

:ACT
slmgr.vbs -ato
echo.
echo.
echo.
GOTO ENDED

I would really appreciate for any help and advice. Thank you!


Solution

  • There are quite a few issues in your batch file. The following should have the flow I think you're after but you'll need to check the handling of slmgr.vbs and its parameters.

    @ECHO OFF
    
    pause
    
    :WinActivation
    SET WIN7Act=
    CLS
    ECHO.
    ECHO.
    ECHO ------------------------------------
    ECHO - Activate Windows 7 Non-VL... -
    ECHO ------------------------------------
    
    SET /P WIN7Act=Input PRODUCT KEY and press [ENTER] (X to exit):
    IF "%WIN7Act%" == "" GOTO WinActivation
    
    IF /I "%WIN7Act%"=="X" EXIT /B
    
    slmgr.vbs -ipk %WIN7Act% -ato
    echo.
    echo.
    echo.