I need to create a service remotely and would rather not break out to a command and run "sc \remotemachine create ......" and want to do it within the C# code.
However, when running the code even though the sc command works quite happily and thus is managing the remote system the ManagementScope.Connect call is throwing an exception with "The RPC server is unavailable."
A snippet of code that does this is
string machineName = "othermachine";
string path = string.Format(@"\\{0}\root\cimv2", machineName);
ManagementScope scope = new ManagementScope(path);
scope.Connect();
as this is about the first step on the journey I'm a bit stuck as to where to go next. The sc command works, so what is it doing different (other than not using .net libraries - maybe I need to hit the winapi harder?)
Thanks