Monday, December 26, 2011

Auto KMS schedule fix

Fix for Auto KMS (EZ-Activator / Microsoft Toolkit) schedule (it wants to run at every reboot + every day, while required only once per 180 days, so we changing it to run once per month).

Place these files at AutoKMS folder and run AutoKMS.bat by hands (from admin account) once.


AutoKMS.bat
c:
cd c:\windows\AutoKms
start /WAIT AutoKMS.exe
c:
cd c:\windows\AutoKms
powershell -command "Set-ExecutionPolicy RemoteSigned"
powershell -file autokms.ps1 > autokms.schedulelog
powershell -command "Set-ExecutionPolicy AllSigned"

AutoKMS.ps1
$n = "AutoKMS"
$s = new-object -com("Schedule.Service")
$s.connect()
$f = $s.getfolder("\")
$t = $f.gettask($n)
$d = $t.Definition
$r = $d.Triggers.Item(1)
$r.DaysInterval = 30
$r = $d.Triggers.Item(2)
$r.Enabled = $false
$a = $d.Actions.Item(1)
$a.Path= $a.Path.replace(".exe", ".bat")
$f.RegisterTaskDefinition($n, $d, 0x24, $null, $null, 5, $null)