views:

1771

answers:

2

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?

A: 

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().

Uros Calakovic
A: 

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.

Ravenlark