I'm trying to rearm windows from within a vb.net app without the need of slmgr.vbs, so I'd like this code to be in vb.net: Code: Dim objService set objService = GetServiceObject("Version") On Error Resume Next objService.ReArmWindows() QuitIfError() LineOut GetResource("L_MsgRearm_1") LineOut GetResource("L_MsgRearm_2") So without all the carbage this should rearm: Code: Dim objService set objService = GetServiceObject("Version") objService.ReArmWindows() But pasting this in notepad and running as vbs throws the error: Types don't match: 'GetServiceObject' GetServiceObject also isn't recognized by vs. Is there anyone who know's how to do it? Thanks, Stannieman
Look at slmgr.vbs again. There is a whole func you are missing Code: Function GetServiceObject(strQuery) Dim objService Dim colServices On Error Resume Next Set colServices = g_objWMIService.ExecQuery("SELECT " & strQuery & " FROM " & ServiceClass) QuitIfError() For each objService in colServices QuitIfError() Exit For Next set GetServiceObject = objService End Function
Just incase anyone stumbles across this after googling like I did, here it a simple way to change the license key for windows 7 pro MAK without using slmgr.vbs I hope by looking at this code you will be able to determine what is the minimal amount of vbs code you need to make your own solution, whether it is vb.net or autoit etc and be able to get the relevant parts out of slmgr.vbs if you need to add extra functionality. activatewin7.vbs Code: Option Explicit Dim g_objWMIService, g_strComputer, g_strUserName, g_strPassword, strProductKey g_strComputer = "." strProductKey = "HYF8J-CVRMY-CM74G-RPHKF-PW487" private const ServiceClass = "SoftwareLicensingService" Set g_objWMIService = GetObject("winmgmts:\\" & g_strComputer & "\root\cimv2") InstallProductKey strProductKey Private Sub InstallProductKey(strProductKey) Dim objService, objProduct On Error Resume Next set objService = GetServiceObject("Version") strVersion = objService.Version objService.InstallProductKey(strProductKey) End Sub Function GetServiceObject(strQuery) Dim objService Dim colServices On Error Resume Next Set colServices = g_objWMIService.ExecQuery("SELECT " & strQuery & " FROM " & ServiceClass) For each objService in colServices Exit For Next set GetServiceObject = objService End Function activate_test.cmd Code: @echo off&cls cscript "%~dp0activatewin7.vbs" cscript "%windir%\system32\slmgr.vbs" /dlv pause You change the strProductKey in the vbs script and then use the batch file to test it. The batch script runs your cd key changer and then it uses slmgr.vbs to verify if the cd key has changed. Good luck for any other future coders