我如何执行位于服务器上的应用程序?

问题描述 投票:0回答:1

我需要将在我们的服务器上托管的调用程序。我尝试在本地PC上执行此程序,并且ewerything很好。我使用了System.Diagnostics中的Process类。但是,当应用程序在服务器上时,它将是什么样子。可以使用该应用程序的窗口吗?

c# asp.net-core asp.net-web-api server client
1个回答
0
投票

您可以使用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);
}
© www.soinside.com 2019 - 2024. All rights reserved.