我需要将在我们的服务器上托管的调用程序。我尝试在本地PC上执行此程序,并且ewerything很好。我使用了System.Diagnostics中的Process类。但是,当应用程序在服务器上时,它将是什么样子。可以使用该应用程序的窗口吗?
您可以使用WMI在远程服务器上执行进程/应用程序。
public static void ExecuteProcess(string serverName,string path)
{
var processToRun = new[] { path };
var connection = new ConnectionOptions();
connection.Impersonation = ImpersonationLevel.Impersonate;
var wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\cimv2", serverName), connection);
var wmiProcess = new ManagementClass(wmiScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
wmiProcess.InvokeMethod("Create", processToRun);
}