4

I am using this code to open process in remote machine:

    Process process = new Process();
    ProcessStartInfo psi = new ProcessStartInfo(@"D:\tools\PsExec\PsExec.exe");
    psi.UseShellExecute = false;
    psi.RedirectStandardOutput = true;
    psi.RedirectStandardError = true;
    psi.RedirectStandardInput = true;
    psi.WindowStyle = ProcessWindowStyle.Minimized;
    psi.CreateNoWindow = true;
    psi.Arguments = "\\\\192.168.0.100 -u user-p pass D:\\app.exe";
    process.StartInfo = psi;
    process.Start();

on the remote machine i can see that the process start but i cannot see my Application GUI.

Double click on the exe will open the GUI

enter image description here

bland
  • 1,968
  • 1
  • 15
  • 22
user1860934
  • 417
  • 2
  • 9
  • 22

2 Answers2

5

Try using psexec.exe with the -i switch :

psi.Arguments = "\\\\192.168.0.100 -i -u user -p pass D:\\app.exe";

or

psi.Arguments = "\\\\192.168.0.100 -i 0 -u user -p pass D:\\app.exe";

use 1 instead of 0 if you are using vista or higher. User desktop runs in session 1 in vista or higher.

jester
  • 3,491
  • 19
  • 30
  • Yes, via remote desktop – user1860934 Oct 28 '13 at 11:23
  • can u try psi.Arguments = @"\\192.168.0.100 -i 0 -u user -p pass D:\app.exe" – jester Oct 28 '13 at 11:25
  • Now i get message in the remote machine: a program running on this computer is trying to display message and after click on view this message i can see my application form but the desktop is in grey and i cannot see nothing except my form until click on Return now – user1860934 Oct 28 '13 at 11:28
  • try 1 instead of 0 in the command if you are using vista or higher. User desktop runs in session 1 for vista or higher (for the -i flag) – jester Oct 28 '13 at 11:34
3

You must to specify the -i parameter with the current userID by default it is 0, in order to get the current logged user ID use: quser /SERVER:remoteComputer , in my case it returned 2, so, it is : -i 2 I hope it works for you.

Sofy
  • 31
  • 1