如何在远程服务器上启动进程?

时间:2017-09-05 06:24:14

标签: c# server

我正在尝试启动命令提示符进程,远程启动服务器并向其写入命令并执行。我遇到的问题是该过程以后台进程开始。 即便如此,作为后台进程可以将命令写入.cmd并执行它吗?

希望我足够明确。

这是我的代码。

var connection = new ConnectionOptions();
connection.Username = @"xxxx";
connection.Password = "xxxxx";


ManagementScope WMIscope = new ManagementScope(string.Format("\\\\{0}\\root\\cimv2", REMOTE_SERVER_NAME), connection);
WMIscope.Connect();

ManagementClass WMIprocess = new ManagementClass(WMIscope, new ManagementPath("Win32_Process"), new ObjectGetOptions());

object[] process = { "cmd.exe" };

object result = WMIprocess.InvokeMethod("Create", process);

0 个答案:

没有答案