0

So i am building an interface using WPF, which will launch a WPF application on different machines in the same network using PsExec commands.

Example:

private static void _remotelyOpenEXE(string psEpath, string ipv4LocalAdd, string userName, string passWord, string path)
{
  ProcessStartInfo psi = new ProcessStartInfo(psEpath, string.Format("\\\\{0} -i 1 -d -u {1} -p {2} {3}", ipv4LocalAdd, userName, passWord, path));

  psi.UseShellExecute = false;
  psi.CreateNoWindow = false;
  Process.Start(psi);            
}

Now that's the easy part, what i want to do is interact with each application loaded, and control each specific WPF app in each machine specifically, for example clicking buttons, retrieve information such as a list which is present in that GUI.

I can easily monitor process using this sample code:

Process[] proc = Process.GetProcesses(GetMachineNameFromIPAddress(ipv4LocalAdd));
foreach (var p in proc)
{
    //can list each process now
}

private static string GetMachineNameFromIPAddress(string ipv4LocalAdd)
{
    string machineName = string.Empty;
    try
    {
       IPHostEntry hostEntry = Dns.GetHostEntry(ipv4LocalAdd);

       machineName = hostEntry.HostName;
    }
    catch (Exception ex)
    {
       Console.WriteLine(ex.Message);
       return string.Empty;
    }
    return machineName;
}

Now, how do i go about controlling each application?

boop_the_snoot
  • 3,209
  • 4
  • 33
  • 44
  • i don't think you can do something like that. What i will do is implement a tcp service that start with the application and send input to it – VeNoMiS Sep 02 '17 at 11:04
  • you can send UDP packets among these applications in some specific format. Fetch those packets and do operations based on the received information – boop_the_snoot Sep 02 '17 at 11:13
  • Is there any example i can take a look at? – TricksterJoe Sep 02 '17 at 11:38
  • Yes ofcourse, [this](https://stackoverflow.com/questions/12864999/sending-and-receiving-udp-packets) is a simple version. – boop_the_snoot Sep 02 '17 at 11:41
  • Hey @Nobody i just skimmed through the solution and it seems like i will also have to establish a listener on the app that i would want to use, but the app is not open source, is there anything else i can do? – TricksterJoe Sep 02 '17 at 11:59
  • Doesn't matter, you can specify specific ports and Ip addresses to listen to and also while sending the info you can customise it to recognize your application only. Though UDP works if only the computers running the apps are connected to the same network. I've implemented the same, that is why I suggested. apart from this I don't know any other method. Sorry! – boop_the_snoot Sep 02 '17 at 12:02
  • Yes, the computers are all under the same network, what you described would be perfect but i tried to find more info specifically regarding my issue but all i see is the same solutions which specifically say i need to establish a listener [inside] the application i want to control, so if you have any more information you could provide me with i'd appreciate it very much! – TricksterJoe Sep 02 '17 at 12:08
  • @Dimakossover well you can hookup on userdll and emulate mouse\keyboard remotly (in this case you ship another application that has the listener) kinda like vnc\teamviewer forward your input to the remote machine – VeNoMiS Sep 02 '17 at 12:10
  • Oh yes, i thought about using it (infact i have a whole interfaces which does that) but i guess the issue i was facing is how to directly send those inputs/sendmessages to that machine (based on ipv4 add) – TricksterJoe Sep 02 '17 at 12:13
  • If you still haven't figured out what to do and if you are not willing to go through UDP track, have a look at [TestStack.White](https://github.com/TestStack/White) or take some help from [rdp](https://www.codeproject.com/Articles/43705/Remote-Desktop-using-C-NET) – boop_the_snoot Sep 02 '17 at 15:33
  • @Nobody i have decided to go with a multi client server (system.net using sockets) which will communicate with main server in a host PC, and send requests from server to a specific client, that actually makes everything much easier, thank you for your help! – TricksterJoe Sep 02 '17 at 15:52

0 Answers0