SSH into remote Windows, execute exe with arguments help

I have an exec node which correctly connects to my PC via SSH, and I want to send a command when it does, but the exec returns code 0 (executed with no errors), but the command doesn’t run (it’s a command to adjust the brightness via controlmymonitor.exe, by Nirsoft).

The flow is like this: Inject → function → exec node with command ‘ssh USER@hostname’ and append msg.payload to exec, and spawn mode on.

the function is like this:


const value = 25; // Use msg.payload for a dynamic value

const command = `"C:\\_automationScripts\\controlmymonitor\\ControlMyMonitor.exe" /SetValue "\\\\.\\DISPLAY1\\Monitor0" 10 ${value}`;

msg.payload = command;

return msg;

now I’m not sure if I properly escaped the slashes (i’m sure I didn’t), but the return code shows as 0 on exec. Could someone please help me with fixing this function?

Once I have it corrected that value constant will be changed to a numeric value returned by a number slider.

On the controlmymonitor page the command line to change the brightness is like so: ControlMyMonitor.exe /SetValue "\\.\DISPLAY1\Monitor0" 10 100

local command line using that example works. Trying to do this via exec does not.

SSH is fine, I do get a proper return in debug with my local terminal responding.

SSH in HA is a bit tricky. The SSH command that you have now will only work inside the terminal container’s command line. HA is a group of containers and each needs it’s own set of keys stored in it’s container.

One way to approach this is to create a shell command inside HA that you can execute from nodered. As I mentioned the command you have now is limited to it’s terminal, follow this guide to use keys stored inside HA’s container.

There are also ssh nodes for NR that let you add your own keys like big ssh but the node hasn’t been updated for 3+ years.