WMI 개체 (Win32_Service)에서 일부 속성을로드하려고하는 C# 코드가 있습니다. 그러나 그것은 나에게 'System.Management.ManagementException : 잘못된 클래스'오류를 반환합니다.Win32_Service가 없습니다.
내 간단한 코드 : 또한
static void Main(string[] args)
{
string serviceName = "AppFabricEventCollectionService";
string propertyName = "StartName";
var obj = GetProperty(serviceName, propertyName);
}
private static string GetProperty(string serviceName, string propertyName)
{
using (ManagementObject obj2 = GetWindowsServiceManagementObject(serviceName))
{
return (obj2.GetPropertyValue(propertyName) as string);
}
}
public static ManagementObject GetWindowsServiceManagementObject(string serviceName)
{
return new ManagementObject(string.Format("Win32_Service.Name='{0}'", serviceName));
}
내가 PowerShell 명령에 의해 WMI 오브젝트의 목록을로드하려고했습니다 -
가져-WmiObject를 -List | 이름 선택
91 개의 개체를 반환하지만 Win32_Service 개체가 누락되었습니다. 나는 그것을 다시 설치하는 방법을 봤지만 찾지 못했습니다. 어떻게 든 다시 설치하는 방법이 있습니까? PowerShell 명령에 대한 출력 :
는업데이트 1 감사
PS C:\Windows\system32> Get-WmiObject Win32_Service
Get-WmiObject : Invalid class "Win32_Service"
At line:1 char:1
+ Get-WmiObject Win32_Service
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [Get-WmiObject], ManagementExce
ption
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.C
ommands.GetWmiObjectCommand
(... 물론, 관리 명령 행) 기본 클래스를 재 등록하십시오 | 이름을 선택하시오? – nimizen
nope. 작동하지 않습니다. 업데이트 1에 출력을 추가했습니다. –
어떤 OS입니까? – nimizen