Our application should start the process on a remote computer (in the same domain as the client machine) as the current (non-administrative) user, and transfer this remote process to the client through WCF. We use the WMI classes in System.Management to start the remote process. My problem is that when I start this method, the remote process encounters a denial of access error when trying to use the Net.Tcp port sharing service. We are quite experienced with the problems associated with sharing WCF and TCP ports on Windows, and we are aware of various errors that may occur when trying to modify SMSvcHost.exe.config. The same process, manually started on the same computer as the same user, works great. Only when starting through WMI does the problem arise. The exception is:
System.ServiceModel.CommunicationException: The service endpoint could not listen to the URI 'net.tcp: // localhost / blah' because access was denied. Verify that the current user is accessing the appropriate allowAccounts section of SMSvcHost.exe.config. ---> System.ComponentModel.Win32Exception: access denied
I understand that this is the same exception that you would get if the port exchange is not configured correctly for the current user, so I would like to emphasize again that the port sharing is configured and therefore would like to avoid answers that refer to me on links explaining how to configure it. Added both the SID and several of its groups. This issue is specifically related to a process that is created remotely through WMI. I assume that the process created by WMI should have a slightly different security context that prevents access to port sharing, but I cannot determine what the critical difference is.
Here is the client-side code that starts the remote process:
private void SpawnRemoteService(string host, string cmd, string args)
{
ManagementScope scope = new ManagementScope(@"\\" + host + @"\root\cimv2");
var path = new ManagementPath("Win32_Process");
using (var proc = new ManagementClass(scope, path, null))
{
using (var start = new ManagementClass("Win32_ProcessStartup"))
{
using (var createParams = proc.GetMethodParameters("Create"))
{
createParams["CommandLine"] = String.Format("{0} {1}", cmd, args);
createParams["ProcessStartupInformation"] = start;
using (var ret = proc.InvokeMethod("Create", createParams, null)) ;
}
}
}
}
, ServiceHost, .