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. NienteNada 21 Reputation points
    2022-08-20T13:27:32.883+00:00

    I thought about that, but this would probably only work for windows devices, wouldnt it?

    I thought if its working via ssh, then I could also launch a print job from an android device for example.


  2. NienteNada 21 Reputation points
    2022-08-13T12:49:59.557+00:00

    @Limitless Technology : I have now deactivated the UAC, according to https://www.lifewire.com/disable-uac-in-windows-10-5113191. Unfortunately that didn't do anything.

    Thanks for the tip @MotoX80 . I used calc.exe as an example for an application with a GUI and thought that other programs should also work accordingly. That was obviously too simple a thought.
    Originally I wanted to trigger a print process from the client. Locally on the host I could use the PDFtoPrinter.exe to start printing from the command prompt. Unfortunately that didn't work over ssh. So I wanted to limit the number of possible causes and had renamed the exe file so that when run it only opens a help window and nothing else. Now I see that this brings its own difficulties. I have no idea how to run notepad.exe via ssh in such a way that a window actually opens on the host.
    On closer inspection, I discovered that the PDFtoPrinter.exe always starts a PDFXCview.exe. This process must be killed in order for printing to start.
    So I was now able to successfully start a print process via ssh by killing the PDFXC process after running the PDFtoPrinter.exe:

    taskkill /IM PDFXCview.exe /F  
    

    But now I'm dealing with the next problem. If I connect via ssh and run the two commands one after the other, then I can print. I'm trying to automate this with Putty. For this I use a cmd file with the following content:

    putty.exe -ssh user@ip_address -pw "xxxx" -m ".\bin\script_1.txt"  
    putty.exe -ssh user@ip_address -pw "xxxx" -m ".\bin\script_2.txt"  
    

    It seems to be not possible to have multiple command lines in one script and run the script with putty, so I have one script for running the PDFtoPrinter commmand and the other to kill the PDFXC-process. Unfortunately, Putty hangs at the first command. However I can see that the command has been successfully executed because both the PDFtoPrinter process and the PDFXC process are started on the host. However, Putty doesnt continue with Script 2. As soon as I delete the PDFXC process manually via a separate ssh session, Putty obviously also continues.

    I tested this with other commands, so this should generally work like that. It has something to do with the print command because putty seems to be waiting for something here.
    I would be very grateful for ideas and hints.

    0 comments No comments

  3. NienteNada 21 Reputation points
    2022-08-20T11:58:01.98+00:00

    I have now solved this with a batch file by automatically ending the process after 3s. Unfortunately, the result is still disappointing because the whole process doesn't always work.
    It seems the PDFXCview.exe process cannot always be successfully terminated on the host. I don't know what's causing this, because if I run the commands one after the other via ssh, it always works perfectly.
    Overall it feels like everything I try isn't really meant for it. What do you think about that?
    My basic idea was to use an old notebook and an old USB printer in such a way that I can print from any end device via the home network using ssh. Would you do it completely differently?

    Here is the content of the batch file:
    233066-screenshot-2022-08-20-135517.png
    As explained, I couldnt find a way to run multiple commands using putty like that, thats why I simply use separate txt-files for each command. Here are the commands:
    script1:

    C:\Users\user\Desktop\print_list\PDFtoPrinter.exe C:\Users\user\Desktop\print_list\*.pdf "HP Photosmart C3100 series"  
    

    script2:

    taskkill /IM PDFXCview.exe /F  
    

    script3:

    del C:\Users\DellE6430s\Desktop\print_list\*.pdf  
    

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.