0

I've browsed page after page after page of data on the web and everyone seems to say that you cannot have an executable remotely execute an application on another machine via WMI and have the window of that application display.

Does anyone know a way around this?

I have tried created 2 executables. 1 executable uses the Process class and simply starts an executable. Here's the code:

 class Program
 {
      static void Main( string[ ] args )
      {
           ProcessStartInfo startInfo = new ProcessStartInfo();
           startInfo.CreateNoWindow = false;
           startInfo.UseShellExecute = false;
           startInfo.FileName = "C:\\folder\\Mexe.exe";
           startInfo.WindowStyle = ProcessWindowStyle.Normal;
           //p.MachineName="server";
           //p.Start(startInfo);
           Process p = Process.Start( startInfo );
      }
 }

This executable resides on the remote machine.

I have another executable that will be on the client's machine. This exe uses WMI in C# to remotely execute the application on the server via the commandline. I get a return code of 0. Nothing happens on the server.

Any ideas what I might be doing wrong?

I've also thought about creating a scheduled task in task scheduler on the server, but leaving the task disabled.

Anyone have an idea what the C# code would be to have a WMI application kick off this task? Would there be a way to discern whether the task/application started finished?

4

3 回答 3

1

You have to use Win32_ScheduledJob.Create to create an interactive process remotely I believe.

See

http://msdn.microsoft.com/en-us/library/aa389769%28VS.85%29.aspx

You can just schedule it for Now +1 second.

于 2009-11-24T22:36:54.857 回答
0

If your command line string is OK, the process name (Mexe.exe) should appear in the process list in Windows Task Manager even if it is invisible. I have also seen information that you can use scheduled tasks to make the process visible, but never tried it. Once you confirm that the process gets created you could try creating a scheduled task for it and running it using Win32_Process.Start().

于 2009-01-24T14:42:49.427 回答
0

您可能已将“Mexe.exe”作为控制台应用程序。在您的代码中,startInfo 描述了一个 Windows 应用程序。尝试将“Mexe.exe”制作为 Windows 应用程序。我已经为控制台和 Windows 应用程序尝试了您的代码,它适用于 Windows 应用程序。

您也可以直接使用客户端上的一个可执行文件来执行此操作。无需中间服务器可执行文件来调用“Mexe.exe”。只是提高性能的建议..

于 2011-10-28T06:20:15.117 回答