Created
October 31, 2017 15:36
-
-
Save qgrosperrin/4d1dea6923c46dccb1b1c7693f78e794 to your computer and use it in GitHub Desktop.
Create & Enumerate All COM Objects (by subTee)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Constant for HKEY_LOCAL_MACHINE... | |
var HKCR = 0x80000000; | |
/* | |
Const HKCR = &H80000000 'HKEY_CLASSES_ROOT | |
Const HKCU = &H80000001 'HKEY_CURRENT_USER | |
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE | |
Const HKU = &H80000003 'HKEY_USERS | |
Const HKCC = &H80000005 'HKEY_CURRENT_CONFIG | |
*/ | |
// Get an instance of the StdRegProv class... | |
var objService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default"); | |
var objReg = objService.Get("StdRegProv"); | |
// Prepare the EnumKey method... | |
var objMethod = objReg.Methods_.Item("EnumKey"); | |
var objParamsIn = objMethod.InParameters.SpawnInstance_(); | |
objParamsIn.hDefKey = HKCR; | |
objParamsIn.sSubKeyName = "CLSID"; | |
// Execute the method and collect the output... | |
var objParamsOut = objReg.ExecMethod_(objMethod.Name, objParamsIn); | |
// If successful, iterate the subkeys... | |
if (objParamsOut.ReturnValue === 0) { | |
if (objParamsOut.sNames != null) { | |
var a = objParamsOut.sNames.toArray(); | |
for (var i = 1; i < a.length; ++i) { | |
//WScript.Echo(a[i]); | |
var len = (a[i].length - 1); | |
//WScript.Echo('clsid:' + a[i].substring(2,len)+ ''); | |
var x = 'clsid:' + a[i].substring(1,len)+ ''; | |
try { | |
WScript.Echo(x); | |
var y = GetObject(x); | |
} | |
catch(exception){ | |
WScript.Echo("Failed" + x); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment