1
Answer

Check if other PCs in network running the program

Photo of TAN WhoAMI

TAN WhoAMI

11y
1.1k
1
I want to check if certain program is executing from other PCs in the network. I test with below code, which works for local PC. How do I extend to check for other PCs in the network?

thanks.

using System;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;

class Program
{
  static void Main(string[] args)
  {
    bool isRunning = Process.GetProcessesByName("Abc")
                .FirstOrDefault(p => p.MainModule.FileName.StartsWith(@"X:\ABC\test\Bin")) != default(Process);
    
    if (! isRunning)
       MessageBox.Show("nothing");
    else
      MessageBox.Show("run");
   
  }
}

Answers (1)