starting a program on a remote machine in wmi, but also opening the apps window (in c#)

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?

3 thoughts on “starting a program on a remote machine in wmi, but also opening the apps window (in c#)

  1. user

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

    Reply
  2. user

    you might have made ‘Mexe.exe’ as a console application. In your code , startInfo describes a windows application. try making the ‘Mexe.exe’ as a windows application. i have tried your code for both console and windows application and it worked for windows application.

    And also you can do this directly with just one executable on client.No need of an intermediate server executable to invoke ‘Mexe.exe’. Is just a suggestion to improve perfomance..

    Reply

Leave a Reply

Your email address will not be published.