4

I have a GUI application running on a windows XP client machine. I would like to telnet in, shut it down, pull some files over via ftp and then start it up again.

It's that last part that I'm having problems with as it seems like starting any GUI app from telnet "starts" it only in the sense that it is added to the process list. It does not pop up forms or really start doing anything (like writing log files).

Try it yourself. Telnet localhost => notepad.exe

Is there a simple way around this limitation? I also have RAdmin installed on all these machines, maybe there's a way to somehow use it? I doubt it since this is for an automation script and my experience is that RAdmin has 0 support for this.

By the way, I started this discussion on stackoverflow and it was recommended to me that you guys might know a thing or two about this.

George Mauer
  • 479
  • 3
  • 7
  • 13

8 Answers8

9

It looks like this is not possible with the Windows telnet service. I even tested running the service under the local system account with "interact with desktop" enabled, but that did not work (which is fine as it would have serious security implications).

As an alternative to using telnet, I would recommend PsExec. PsExec is part of the SysInternal tools now managed by Microsoft. Use the -i option to enable desktop interaction.

psexec \\machine -u user -p password -i -w "C:\application" myapp.exe

You can download PsExec here.

Doug Luxem
  • 9,612
  • 7
  • 50
  • 80
5

See http://msdn.microsoft.com/en-us/library/ms687096(VS.85).aspx for a long and detailed though ultimately unhelpful description of what is happening when you launch apps from a telnet session. Many years ago I wrote a telnet server for Windows NT3.50 and I learned all this stuff the hard way :-)

I think you need to look again at what you're trying to do. From your description I'd guess that you have some GUI app being run by a logged in user and you want to kill it so you can do some maintenance then restart it. Killing it is easy as you can just kill the process. Restarting it in any useful way is harder. Could you set the PC to autologin and run the app from the Start Menu? Then you could just restart the PC when you've grabbed your files. I'm somewhat ashamed to admit this is what I did under similar circumstances.

JR

John Rennie
  • 7,776
  • 1
  • 23
  • 35
  • Thanks JR, I think rebooting might just be what I have to do. Its not slick but it would be acceptable especially if this is running late at night or something. Oh well. – George Mauer Jun 11 '09 at 14:17
2

This shouldn't be possible to interact with any GUI apps because the telnet server doesn't provide you with access to a window station in which the GUI app run. In order to run a remote Windows GUI app, you need to start it within a terminal services session (or similar).

Brian Reiter
  • 860
  • 5
  • 8
2

Do you have to use Telnet? Remote Desktop would allow you to stop and start the program interactively, and you could still use FTP to move the files. The downside: the remote computer will be locked once you disconnect, and if you log off, the program will stop running.

Jay Michaud
  • 3,973
  • 4
  • 23
  • 36
  • Is it possible to automate remote desktop though? – George Mauer Jun 12 '09 at 18:37
  • Could you be more specific? What about the remote desktop session do you want to automate? – Jay Michaud Jun 12 '09 at 22:24
  • @JayMichaud, this is similar to what I am also looking at.. I would like to automatically log in via RDP, then run the GUI program. I want to do all this programmatically.. without a real user sitting in front of a Desktop.. Is it possible using RDP? – alpha_989 Mar 14 '18 at 17:53
2

as mentioned above PsExec (sysinternals) provides the solution it is the -i flag which allows the gui creation on the target

with the -d flag your call doesn't hang (background execution) as it would else wait for the application termination

now for secure remote execution you might want to execute it though ssh for windows in this case freeSSHD is a solution mind to execute it as the target user so all spawning happens with the same user (don't execute freeSSHD as SYSTEM but with yourUsername)

an example of Acrobat executed from within putty

C:\PsExec.exe \\127.0.0.1 -d -i "C:\Program Files\...\AcroRd32.exe"


one other thing to possibly consider using psexec is that v1.55 did not support session ID where as the current one v1.9x does

so instead of "-i" it might be for
xp/nt systems "-i 0"
vista/7 systems "-i 1"

ebricca
  • 131
  • 3
0

Try the "start" command. It supports starting Windows apps, but I must confess I've never tested it over a telnet session.

Maximus Minimus
  • 8,987
  • 2
  • 23
  • 36
  • Nope, GUI doesn't pop up. I've also tried runas with no effect. I'm not quite sure whats going on honestly. Ok, maybe the forms open on some hidden desktop somewhere but log4net should be logging to a file! Why in the world is that not happening? – George Mauer Jun 10 '09 at 22:08
0

Windows Processes are linked to a Windows Session Id. Different processes can only interact if they share the same Session ID, or Desktop.

This blog by Brian Bondy explains all of this, and more, including ways to circumvent all Windows Security (By running a Service under the Local System Account).

Henk Langeveld
  • 1,314
  • 10
  • 25
0

On the windows servers there exist a tool schtasks.exe
Which is the task manager but in the command line.
This may be an alternative to run a gui app on a remote machine.
To start a gui app immediately the task should be "created" (schtasks.exe /create) with past time and subsequent issuing of the command schtasks.exe /run with same task name parameter.
It is tested and it have been proven to be fully functional over a telnet connection.
the relevant help page https://technet.microsoft.com/en-us/library/cc772785(v=ws.10).aspx

user3694243
  • 101
  • 4