Run executable via ssh

NienteNada 21 Reputation points
2022-08-09T05:23:42.427+00:00

Hello everyone,

I am trying to figure out: What can be the reason why the same executable, which works fine being launched locally, does not work being launched via ssh although all other conditions are unchanged.

I am trying to run the PDFtoPrinter.exe

http://www.columbia.edu/~em36/pdftoprinter.html

remotely from another Windows10-Computer via SSH, but it doesnt work.

To isolate the problem, I have both Windows10 PCs, the host and the client, side by side. Here's what I've tried:

I renamed the file to PDFtoPrinterSelect.exe on the host. When I run the command "C:\Users\Desktop\PDFtoPrinterSelect.exe" in the host-Terminal, it works fine and a help window opens.

When I connect via OpenSSH to the host, and run the same command, nothing happens, without any error messages. Same via PuTTy.

So I tried "runas /user: C:\Users\Desktop\PDFtoPrinterSelect.exe", but still nothing happens.

For example, when I run the calc.exe command (via ssh from the client), it actually opens the Calculator app on the host PC. So it is generally possible to run executables via ssh, which open a gui. So for me its not clear why its not working with the PDFtoPrinter program. Does anybody have an idea?

Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

Accepted answer
  1. Limitless Technology 39,916 Reputation points
    2022-08-09T14:15:58.393+00:00

    Hello,

    This may be related to the strengthened security on Printer Driver access from Microsoft in the latest releases.

    My suggestion is to try to disable UAC in the machine, as with OpenSSH it will not start an interactive session and any UAC restriction will not be displayed.

    Reference for steps: https://learn.microsoft.com/en-us/troubleshoot/windows-server/windows-security/disable-user-account-control

    -----------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--

    1 person found this answer helpful.
    0 comments No comments

7 additional answers

Sort by: Most helpful
  1. MotoX80 36,291 Reputation points
    2022-08-09T21:06:22.167+00:00

    I see that. But it does not work with other apps like notepad, mmc, and wordpad.

    I will speculate that it has something to do with UWP applications. When I launch C:\Windows\System32\calc.exe what ends up running is C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.2103.8.0_x64__8wekyb3d8bbwe\Calculator.exe.

    229693-capture.png

    But traditional Windows apps like notepad and your PdftoPrinter run as child processes of sshd/cmd. Since I have the SSHD process running as a service, I do not have any way to interact with the GUI.

    229694-image.png

    https://learn.microsoft.com/en-us/sysinternals/downloads/process-explorer

    1 person found this answer helpful.
    0 comments No comments

  2. MotoX80 36,291 Reputation points
    2022-08-13T14:17:57.823+00:00

    Your number 1 problem is message boxes. Those just do not work in an SSH session.

    From the link that you posted I see the source code.

    http://www.columbia.edu/~em36/PDFtoPrinter.au3

    It is looking for "cli" in @ScriptName to use console output instead of a msgbox. Scriptname appears to be the executable name, but i've renamed the .exe and can't get any console output.

    See the "source code" section on that page. You may want to contact the author or compile the code yourself to force it to write to the console.

    As far as the putty -m switch, i think that you would be better off having SSH call a .bat file or a Poweshell script, where you can look for hung processes, kill them, and then start a new print process and wait for that to complete.

    1 person found this answer helpful.
    0 comments No comments

  3. MotoX80 36,291 Reputation points
    2022-08-09T15:14:54.567+00:00

    You can launch a GUI over SSH but you can't interact with it. For that program, you will have to enter a valid command sequence, because you will have no way to know if it works or not other than to see that the program is still running.

    From a desktop command prompt....

    229589-image.png

    In an ssh session....

    229579-image.png

    if you need to run the program over SSH, then it should be a full command line program that only outputs to stdout and stderr. Message boxes are no good.

    0 comments No comments

  4. NienteNada 21 Reputation points
    2022-08-09T16:44:09+00:00

    @MotoX80 : I'm not sure if we understood each other correctly. Of course I can't interact with the GUI on the host PC, that's not my point. After all, these are purely test conditions. I execute a command and expect the corresponding window to open on the host PC. The same way as it works for example with the calc.exe.

    @Limitless Technology : Yes, I thought that it must be something like that, too. But I am not very familiar with the UAC at all.
    Thanks for the tip, I'll try that and report if that helped.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.