I am having problems directly accessing the Win32_OperatingSystem management class that opens through WMI.
This is a singleton class, and I'm sure that "Win32_OperatingSystem = @" is the correct path syntax to get a singleton instance.
InvokeMethod calls the exception at the bottom of the question, as does access to the ClassPath property (comment line).
What am I doing wrong?
[I know that I can use ManagementObjectSearcher / ObjectQuery to return the Win32_OperatingSystem collection (which will contain only one), but since I know this is a singleton, I want to access it directly.]
ManagementScope cimv2 = InitScope(string.Format(@"\\{0}\root\cimv2", this.Name));
ManagementObject os = new ManagementObject(
cimv2,
new ManagementPath("Win32_OperatingSystem=@"),
new ObjectGetOptions());
os.InvokeMethod("Reboot", null);
System.Management.ManagementException Message = " " = "System.Management" : System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus errorCode) System.Management.ManagementObject.Initialize(Boolean getObject) System.Management.ManagementBaseObject.get_wbemObject() System.Management.ManagementObject.get_ClassPath() System.Management.ManagementObject.GetMethodParameters(String methodName, ManagementBaseObject & inParameters, IWbemClassObjectFreeThreaded & inParametersClass, IWbemClassObjectFreeThreaded & outParametersClass) System.Management.ManagementObject.InvokeMethod(String methodName, Object [] args)
.
Nick - , :)
Uros. , - MSDN. , WBEMTest this.
: "1 " " : 1" "Win32_OperatingSystem = @"
ManagementScope , , . WMI, .