Difference between revisions of "Windows Activation"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
Line 106: Line 106:
 
<check type="execute" path='%ComSpec% /c cscript /nologo C:\Windows\system32\slmgr.vbs /dli | find "Lizenziert" > NUL' condition="exitcodeequalto" value="0" >
 
<check type="execute" path='%ComSpec% /c cscript /nologo C:\Windows\system32\slmgr.vbs /dli | find "Lizenziert" > NUL' condition="exitcodeequalto" value="0" >
  
<install cmd='%ComSpec% /c "%SOFTWARE%\WinActivation\remove_proxy.reg"' />
+
<install cmd='%ComSpec% /c "%SOFTWARE%\WinActivation\activation.cmd"' />
 
</package>
 
</package>
 
   
 
   

Revision as of 12:17, 7 August 2014

Windows 7 Activation via Multiple Activation Key (MAK)

<?xml version="1.0" encoding="UTF-8"?>

<packages>

<package
  id="win7_activation"
  name="Windows 7 Activation"
  revision="20100302"
  reboot="false"
  priority="100"
  notify="false"
  execute="once">
  <install cmd="cscript slmgr.vbs -ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX" />
  <install cmd="cscript slmgr.vbs -ato" />
</package>

</packages>

Batch file for activation via key lists for Windows 7, 8 and 8.1. One activation code per line in win_7_pro.txt and used codes will be written into used_win_7_pro.txt as "$KEY $HOSTNAME" so they are marked as used and on which machine.

@echo off

set WPKG_DIR=\\your_server\wpkg

REM Check Windows Version
ver | find "5.1." > nul
IF %ERRORLEVEL% EQU 0 goto WIN_XP
ver | find "6.1." > nul
IF %ERRORLEVEL% EQU 0 goto WIN_7
ver | find "6.2." > nul
IF %ERRORLEVEL% EQU 0 goto WIN_8
ver | find "6.3." > nul
IF %ERRORLEVEL% EQU 0 goto WIN_81
goto WARNING

:WIN_XP
echo XP volume license used
exit /b
goto ACTIVATE

:WIN_7
set KEY_FILE=%WPKG_DIR%\packages\WinActivator\win_7_pro.txt
set USED_KEY_FILE=%WPKG_DIR%\packages\WinActivator\used_win_7_pro.txt
goto ACTIVATE

:WIN_8
:WIN_81
set KEY_FILE=%WPKG_DIR%\packages\WinActivator\win_8_pro.txt
set USED_KEY_FILE=%WPKG_DIR%\packages\WinActivator\used_win_8_pro.txt
goto ACTIVATE

:WARNING
echo Unsupported machine OS.
exit /b

:ACTIVATE  
cscript /nologo slmgr.vbs /dli | find "Licensed" > NUL
if not errorlevel 1 (
	echo Windows is activated.
	exit /b
) else (
	echo Windows is not activated.
	for /F "tokens=*" %%K in (%KEY_FILE%) do (
		findstr /m "%%K" %USED_KEY_FILE% > NUL
		if errorlevel 1 (
			echo unused key found: %%K
			cscript /nologo slmgr.vbs /ipk %%K
			if not errorlevel 1 (
				echo set key successfully.
				cscript /nologo slmgr.vbs /ato
				if not errorlevel 1 (
					echo successfully activated.
					echo %%K %COMPUTERNAME% >> %USED_KEY_FILE%
					exit /b
				)
			)
		)
	)
)

echo something went wrong.
exit /b 1

package file:

<?xml version="1.0" encoding="UTF-8"?>
 
<packages>
 
	<package
		id="winactivation"
		name="Windows Activation"
		revision="1"
		reboot="false"
		priority="100">
		
		<check type="execute" path='%ComSpec% /c cscript /nologo C:\Windows\system32\slmgr.vbs /dli | find "Lizenziert" > NUL' condition="exitcodeequalto" value="0" >

		<install cmd='%ComSpec% /c "%SOFTWARE%\WinActivation\activation.cmd"' />
	</package>
 
</packages>