0

我遇到了一个可能不容易解决的问题,但我希望有人能够提供帮助。我正在尝试运行 exe 以在远程设备上安装某些软件(SCCM 客户端)。

所以发生的事情是我正在从我的 PC (Host1) 运行程序以连接到远程设备 (Host2) 并指示该设备从服务器运行 exe。

我一直在使用标准的远程执行 WMI 代码,但没有运气:

ConnectionOptions connOptions = new ConnectionOptions();
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.EnablePrivileges = true;
ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", Host2), connOptions);
manScope.Connect();
if(manScope.IsConnected)
{
    ObjectGetOptions objectGetOptions = new ObjectGetOptions();
    ManagementPath managementPath = new ManagementPath("Win32_Process");
    ManagementClass processClass = new ManagementClass(manScope, managementPath, objectGetOptions);

    ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
    inParams["CommandLine"] = @sCommand;
    ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
}
else
{
    MessageBox.Show("An error occurerd while attempting to connect to WMI.");
}

我遇到的问题是当 exe 在服务器上时执行 sCommand 。因此,当参数为“\\server\share\program.exe”时,没有任何反应。当参数为“c:\Folder\program.exe”时,效果很好。不幸的是,我们针对的这些设备禁用了 Admin$ 和 C$,并且它们的硬盘上没有 exe。

不幸的是,我不知所措-是否可以使用 Win32_Process.Create 方法来运行 UNC exe,或者是否可以在禁用 Admin$ 和 C$ 时将 exe 甚至它所在的文件夹复制到主机设备? 我试图避免使用 psexec,老实说,我想知道我是否会遇到同样的问题。

4

1 回答 1

0

您不能在远程计算机上部署自定义 Windows 服务应用程序吗?这样,您只需使用所需的任何通道与服务通信并从那里运行可执行文件。

于 2014-02-26T18:47:51.010 回答