How to start a process on another computer in .net

Let's say I have a Windows service called "MyService" and an executable file called "MyEXE" located on several computers on my network.

Is it possible (from within "MyService") to run multiple instances of "MyEXE" on another / the same computer, perform some task and return a true / false result to the callback method in "MyService"?

Something like that

class MyService : ServiceBase
{
    delegate void UpdateCallBack(int id, bool updated)
    void CheckForUpdates()
    {
        bool updatesExist = someService.GetCurrentVersion() != currentVersion;
        if(updatesExist)
        {
            UpdatePC("C:\Program Files\MyApp.exe", 1, UpdateComplete);
            UpdatePC("\\somepc\Program Files\MyApp.exe", 1, UpdateComplete);
            UpdatePC("\\mypc\Program Files\MyApp.exe", 1, UpdateComplete);
        }
    }

    void UpdatePC(string filePath, int id, UpdateCallBack callback)
    {
       //This is where I am kind of lost 
       SomeEXERunner runner = new SomeEXERunner();
       runner.Run(filePath,"-u",id,callback);
    }

    void UpdateComplete(int id, bool updated)
    {
       //do something
       if(!updated)
          EmailService.NotifyAdmin("PC Not updated", id);
    }
}

Maybe I'm wrong in the whole architecture!

+1
source share
4 answers
+10

- psexec, -... , psexec :

  • exe .
  • \\remotesystem\admin $
  • SCM exe \\remotesystem
  • connect .
  • SCM
0

Also see the Task Manager API. You plan to start the task once now + 1 s, etc. It is COM-based, so it is .NET-friendly.

Unlike psexec, this does not install anything on the target machine.

0
source

All Articles