I'm trying to set up a Windows machine as an SSH server so that I can SSH to it from another Windows machine.

I installed OpenSSH on the server and can successfully connect to it from another Windows client using Putty. I'm trying to write a script that will open a specific application and then run an Autohotkey script to perform some action within that application. I have a batch file on the SSH server. If I run that batch file locally it does exactly what I want it to do: it opens the application, runs the Autohotkey script, and exits gracefully. However, if I open that same batch file through an SSH session, the application process starts (I see the process in Task Manager), but the GUI doesn't actually open. From what I've been able to find, it's likely due to the fact that SSH is running as a service and will not open the application as the currently logged in user. To try to circumvent this, I attempted the "runas" command. Again, I have the same outcome (the .exe shows up in Task Manager, but the GUI doesn't open). Additionally, both of these methods open the AHK script but the script doesn't perform any actions.

I've also tried another SSH server, freeSSHd, that does NOT run as a service. Using this, I can get the script to do exactly what I want via SSH. However, this solution doesn't work for me because ideally there won't be any peripherals connected to the SSH server. It will just be connected to the network via Ethernet. If it's not running as a service, that means I'll need to manually open the application and click on the "Start SSH server" button each time it restarts.

How can I open a GUI application over SSH?


  • You could use same account (which you use for log in) for OpenSSH service with administrative privileges. You need to set up correct permissions for this account and allow it to log on as service. Such account needs a password. If password is not desirable during startup, then you could configure autologin. – Michal Sokolowski Dec 6 '17 at 16:48

Services are restricted from showing any UI elements; they get put on a thingy (Desktop or Windows Station or something, doesn't matter at the moment). So anything GUI is not going to work.

You would need a way to create a new thingy, and then put the application that thingy, all from the SSH login session. While it might be possible to build something to do that, it would be a waste of time, since it's already been done. It's called Remote Desktop Connection (RDC), AKA Remote Desktop Protocol (RDP). Use RDP instead of SSH. Use an RDP client instead of an SSH client.

If, for whatever reason, you have to use SSH, use SSH to establish the connection to the computer, and then use SSH port forwarding to tunnel RDP.

If, for some reason, you don't think you can use RDP, please explain why.

  • So the original line of research that led me to using SSH was the question "How do I remotely launch a script from Windows to Windows". Can I use RDP to do that? I thought RDP was only for desktop forwarding. To explain a bit deeper: I'm launching the remote script based on a trigger from another application using a batch file on the client machine. This batch file uses plink.exe (Putty) along with a command file that calls the batch script on the server. – DyslexicHobo Dec 6 '17 at 17:30
  • The issue is that most Windows programs cannot run without a desktop, so you need a desktop. When it comes to automating things in Windows, either the task supports automation without the GUI, or you have to pretend to be a human, and set-up everything there. It might help if you describe the specifics. I.e., don't talk in general terms about "the application". Give us something like, "I'm trying to automate installation of AutoCAD Release 14", or "I'm trying to add a line to an Excel spreadsheet", or "I'm trying to reticulate the splines in Acme Accounting Pro" or whatever. – Ben Scott Dec 6 '17 at 17:49
  • 1
    I'm working with a 3rd party provided navigation simulator. This software (of which we have no control) outputs navigation sensor data to a piece of navigation software. We really don't need to interact with the simulator at all except to restart the simulation. I'm trying to have the simulation restart be controlled by a button on another piece of software running on the same network. – DyslexicHobo Dec 6 '17 at 17:57

So the solution that ended up working was using PSExec (part of PSTools). I briefly tried to get it to work before, but had the same problem (GUI not showing up). The trick was that I needed to use the -i option for an interactive session. Thanks to everyone else for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.