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.

  1. windows+r (run command)

  2. 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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -