C# - Windows Service - Remote WMI query throws error: RPC not found -
i developing wmi query windows service query network servers. if run application in console, works expected service fails complete wmi query. there way can setup service rpc doesn't fail due insufficient privileges? using credentials in wmi query connect remote pc should not problem.
thanks
probable reason:
firewall configuration (rpc connections blockage)
you don't have enough permission run wmi queries.
second point valid if trying run queries on remote machines. can use wbemtest
verify.
windows+r (run command)
type wbemtest
you have connect managementscope
, check it's validity scope.isconnected
. snippet of code, might have provide structure it.
connectionoptions coption = new connectionoptions(); managementscope scope = new managementscope("\\\\" + machine + "\\" + namespaceroot + "\\" + managementscope, coption); scope.options.username = username; scope.options.password = password; scope.options.enableprivileges = true; scope.options.authentication = authenticationlevel.packetprivacy; //scope.options.timeout = timespan.fromseconds(180); //coption.timeout = timespan.fromseconds(180); scope.options.impersonation = impersonationlevel.impersonate; scope.connect(); return scope; if (scope.isconnected && scope != null) { query = new objectquery(@"select * win32_scsicontroller"); searcher = new managementobjectsearcher(scope, query); searcher.options.timeout = new timespan(0, 0, wbemconnectflagusemaxwait); managementobjectcollection qwin32_scsicontroller = searcher.get(); foreach (managementobject item in qwin32_scsicontroller) { <some code here> }
Comments
Post a Comment