【问题标题】:How can I open installed apps same "firefox" on remote computers?如何在远程计算机上打开已安装的应用程序相同的“firefox”?
【发布时间】:2014-06-17 04:32:29
【问题描述】:

我想远程连接到网络中的另一台计算机并远程运行其应用程序。 我使用 WMI 连接到网络 PC,当我尝试通过创建 wmi_process 在其上运行像“firefox”这样的应用程序时,它会在进程任务管理器中创建 firefox.exe,但它不会运行它!( firefox.exe 在背景并且没有打开!)

我也想打开应用程序。我可以这样做吗? 还有其他方法可以远程连接和运行计算机上安装的程序吗? 谢谢...

 public void RunApps(string AppName)
 {
      ObjectGetOptions objectGetOptions = new ObjectGetOptions();
      ManagementPath managementPath = new ManagementPath("Win32_Product");

      string loc = string.Empty;
      foreach (ManagementObject mo in managementObjectCollection)
      {
          if (mo["name"].ToString() == AppName)
          {
              loc = mo["InstallLocation"].ToString();
          }
      }

      loc += AppName + ".exe";

      ManagementClass processClass = new ManagementClass("Win32_Process");
      ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
      inParams["CommandLine"] = loc;// "calc.exe";
      ManagementBaseObject outParams =processClass.InvokeMethod("Create", inParams, null);
 }

【问题讨论】:

    标签: c# network-programming wmi remote-access


    【解决方案1】:

    恐怕这在使用 WMI 时是不可能的。出于安全原因,您不能以这种方式创建交互式远程进程。

    参见微软文档here

    您可以使用 Win32_Process.Create 在 远程计算机。但是,出于安全原因,进程不能 互动。在本地调用 Win32_Process.Create 时 计算机,这个过程可以是交互式的。

    这正是您上面的代码试图做的——因此您可以创建一个进程,但它不能与用户交互(例如,它不能创建一个可见窗口)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-19
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多