i had run a program that remote to get the process name of SCCM server. It is successful to get the process name. but i want to try to call RequestMachinePolicy "invokemethod("RequestMachinePolicy", new object[]{2});. But it is fail and the
error message is "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))". I had search some solution by WMI security problem and follow their instruction but also fail. Does anyone experience this problem?
i had captured my coding for reference:
ManagementScope scope = new ManagementScope("\\\\" + ConnProperty.SERVER + "\\root\\CCM", oConn);
scope.Connect();
Console.WriteLine(scope.IsConnected); <--- it is output "True"
ManagementClass cls = new ManagementClass(scope.Path.Path, "SMS_Client", null);
cls.InvokeMethod("RequestMachinePolicy", new object[] { 0 });
Console.WriteLine("Completed.");
it is the exception errror is below:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Management.ManagementScope.InitializeGuts(Object o)
at System.Management.ManagementScope.Initialize()
at System.Management.ManagementObject.Initialize(Boolean getObject)
at System.Management.ManagementObject.InvokeMethod(String methodName, Object[
] args)
at ConsoleApplication2.UITesting.testManageScope() in C:\Documents and Settings\Administrator\My Documents\CMTesting\ConsoleApplication2\ConsoleApplication2\UITesting.cs:line 678
Does anyone have a suggestion for this problem? Thanks