c# - Win32_Service is missing -
i have c# code tries load property wmi object - win32_service. returns me 'system.management.managementexception: invalid class ' error.
my simplified code:
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) string); } } public static managementobject getwindowsservicemanagementobject(string servicename) { return new managementobject(string.format("win32_service.name='{0}'", servicename)); }
also i've tried load list of wmi objects powershell command -
get-wmiobject -list | select name
it returns 91 objects, misses win32_service object. googled how reinstall it, didn't found it. there way reinstall somehow?
thank you
update 1: output powershell command:
ps c:\windows\system32> get-wmiobject win32_service get-wmiobject : invalid class "win32_service" @ line:1 char:1 + get-wmiobject win32_service + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + categoryinfo : invalidtype: (:) [get-wmiobject], managementexce ption + fullyqualifiederrorid : getwmimanagementexception,microsoft.powershell.c ommands.getwmiobjectcommand
see section "i’m getting 0x80041010 (“invalid class”) error" here. might find useful, in particular use of scriptomatic , wbemtest.
Comments
Post a Comment