PsExec to Remotely run a GUI Application

user96403 picture user96403 · Feb 1, 2012 · Viewed 8.7k times · Source

I am trying to launch a GUI application remotely using PsExec.

            ProcessStartInfo info = new ProcessStartInfo(@"<path to dir>");
            info.FileName = @"C:\<dirpath>\PsExec.exe";
            info.Arguments = @"\\" + "<COmputerName>" + " " + @"""C:\Program Files (x86)\<exepath>\<exename>.exe""";
            info.RedirectStandardOutput = true;
            info.UseShellExecute = false;
            info.RedirectStandardError = true;
            info.WindowStyle = ProcessWindowStyle.Maximized;

            Process o = Process.Start(info);

The issue here is that the process does launch remotely, but I cannot see the GUI. I can only see it in task manager. Is there a way to see the GUI on the remote computer?

EDIT 1: *Permissions*

  1. Console.WriteLine (System.Environment.UserName.ToString());
  2. Console.WriteLine(Thread.CurrentPrincipal.Identity.Name.ToString());
  3. Console.WriteLine ("current winddentity " + System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());

If I execute above lines of code before starting process, it gives:

  • administrator
  • blank
  • DomainName\administrator
  • and I am logged it with the administrator account on the remote computer as well.

    *InteractiveMode* When I try to use the switch -i from the cmd prompt it gives: Process exited with error code -1073741502. While trying to execute using C#, it doesnt do anything at all. No exception at least!

    END OF EDIT 1.

    Answer

    Alex K. picture Alex K. · Feb 1, 2012

    Assuming correct permissions you want -i for interactive mode.

    -i Run the program so that it interacts with the desktop of the specified session on the remote system. If no session is specified the process runs in the console session.

    info.Arguments = @"\\" + "<COmputerName>" + " -i " + @"""C:\Program F...