Difference between revisions of "Windows Activation"

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search
Line 22: Line 22:
 
</source>
 
</source>
  
Batch file for activation via key lists for Windows 7, 8 and 8.1:
+
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.
<code>
+
  
 +
<source lang="dos">
 
@echo off
 
@echo off
  
Line 61: Line 61:
  
 
:ACTIVATE   
 
:ACTIVATE   
REM Noch X Tage bis Ende der vorläufigen Aktivierung
+
cscript /nologo slmgr.vbs /dli | find "Licensed" > NUL
cscript /nologo slmgr.vbs /dli | find "Lizenziert" > NUL
+
 
if not errorlevel 1 (
 
if not errorlevel 1 (
echo Windows ist aktiviert.
+
echo Windows is activated.
 
exit /b
 
exit /b
 
) else (
 
) else (
echo Windows ist nicht aktiviert.
+
echo Windows is not activated.
 
for /F "tokens=*" %%K in (%KEY_FILE%) do (
 
for /F "tokens=*" %%K in (%KEY_FILE%) do (
 
findstr /m "%%K" %USED_KEY_FILE% > NUL
 
findstr /m "%%K" %USED_KEY_FILE% > NUL
 
if errorlevel 1 (
 
if errorlevel 1 (
echo found unused key: %%K
+
echo unused key found: %%K
 
cscript /nologo slmgr.vbs /ipk %%K
 
cscript /nologo slmgr.vbs /ipk %%K
 
if not errorlevel 1 (
 
if not errorlevel 1 (
Line 88: Line 87:
 
echo something went wrong.
 
echo something went wrong.
 
exit /b 1
 
exit /b 1
 
+
</source>
</code>
+
  
 
[[Category:Silent Installers]]
 
[[Category:Silent Installers]]
 
[[Category:Changing Windows settings]]
 
[[Category:Changing Windows settings]]

Revision as of 11:29, 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