Read DWORD via microsoft.management.infrastructure (WMI) on a remote PC

  • Thread starter Thread starter D.Brausch
  • Start date Start date
D

D.Brausch

Guest
Since a few days I'm trying to find a solution to read the "UBR" REG_DWORD from the registry.


Registry PATH: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

With System.management assembly this works great.
See CODE:

ManagementClass ObjManagementClassRegistry = new ManagementClass(_objPublicManagementScope, new ManagementPath("StdRegProv"), null);
ManagementBaseObject inParams = ObjManagementClassRegistry.GetMethodParameters("GetStringValue");
inParams["hDefKey"] = 0x80000002;// HKEY_LOCAL_MACHINE;
inParams["sSubKeyName"] = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion";
inParams["sValueName"] = "UBR";

ManagementBaseObject ObjOutParams = ObjManagementClassRegistry.InvokeMethod("GetDWORDValue", inParams, null);

if (Convert.ToUInt32(ObjOutParams["ReturnValue"]) == 0)
{
var ddd = ObjOutParams["uValue"];
}


Now System.Management will be replaced by Microsoft.Management.Infrastructure Assembly

Now I try to write it under Microsoft.Management.Infrastructure, but I can't get it to work.

I would need a sample code in cSharp. I know that there is something like that with PowerShell, but I don't understand the script :-(

I want to thank you in advance for your help

Greetings Brauschi

Continue reading...
 
Back
Top