node-activex icon indicating copy to clipboard operation
node-activex copied to clipboard

Reading Registry with WbemScripting.SWbemLocator not working

Open Cupidazul opened this issue 4 years ago • 3 comments

Is it possible to replicate Registry Parse with "WbemScripting.SWbemLocator", Reading List of Values ? keep up the great work, this lib is awesome!

example: https://www.dostips.com/forum/viewtopic.php?t=7347&start=30

var vRet = null, iType = -1; var objLocator = new ActiveXObject("WbemScripting.SWbemLocator"); var objService = objLocator.ConnectServer(strComputer, "root\default"); objService.Security_.ImpersonationLevel = 3; //wbemImpersonationLevelImpersonate var objReg = objService.Get("StdRegProv"); var objEnumMethod = objReg.Methods_.Item("EnumValues"); var objEnumInParam = objEnumMethod.InParameters.SpawnInstance_(); objEnumInParam.hDefKey = uHive; objEnumInParam.sSubKeyName = strRegPath; var objEnumOutParam = objReg.ExecMethod_(objEnumMethod.Name, objEnumInParam);

var objGetMethod = objReg.Methods_.Item("GetExpandedStringValue"); var objGetInParam = objGetMethod.InParameters.SpawnInstance_(); objGetInParam.hDefKey = uHive; objGetInParam.sSubKeyName = strRegPath; objGetInParam.sValueName = strValName; var objGetOutParam = objReg.ExecMethod_(objGetMethod.Name, objGetInParam);

Cupidazul avatar Apr 06 '20 12:04 Cupidazul

i`m tested sucessfully, try

var objLocator = new winax.Object("WbemScripting.SWbemLocator");
var objService = objLocator.ConnectServer(".", "root\\default");
objService.Security_.ImpersonationLevel = 3; //wbemImpersonationLevelImpersonate
var objReg = objService.Get("StdRegProv");
var objGetMethod = objReg.Methods_.Item("GetExpandedStringValue");
var objGetInParam = objGetMethod.InParameters.SpawnInstance_();
objGetInParam.hDefKey = 0x80000001; //HKCU;
objGetInParam.sSubKeyName = "Software\\Microsoft\\Windows\\CurrentVersion\\Themes";
objGetInParam.sValueName = "CurrentTheme";
var objGetOutParam = objReg.ExecMethod_(objGetMethod.Name, objGetInParam);
console.log('CurrentTheme: ', objGetOutParam.sValue.valueOf());

may be not enough backslash "root\default"?

durs avatar Apr 06 '20 19:04 durs

great! I'll test just that... Thanks!

awesome lib.

Cupidazul avatar Apr 07 '20 09:04 Cupidazul

ok, close this Issue, It's working just fine. thx.

Cupidazul avatar Apr 07 '20 23:04 Cupidazul