Node-red on Windows exec node issue

I am trying to control my display power on/off with Node-Red installed on the Windows computer. I tried the exec node with multiple commands and external utilities that work perfectly from the command line but fail in NR. I guess there's might be a rights issue, but I autostart NR by scheduler with my own user rights, so it should work. I will appreciate any ideas.

Have you got an example of something that works from command line

I'll try it out on my Win10 setup and see if I can replicate/help out

a common mistake is to leave the "append payload" option ticked - so that gets added to the command line and messes it up.

powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)

or with a full path

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)

and other utilities like

nircmdc.exe monitor off

I also tried to wrap them up into cmd file, but still no effect

Thanks, maybe I put it wrong: I mean they look working, returning no error, but no effect at all.

Worked for me putting the cmd in an inject node

[{"id":"dcce3dc7.7d5bb","type":"exec","z":"51a64297.ac391c","command":"","addpay":true,"append":"","useSpawn":"false","timer":"30","oldrc":false,"name":"","x":484,"y":176,"wires":[["6c3ffb94.b865a4"],["6c3ffb94.b865a4"],["6c3ffb94.b865a4"]]},{"id":"8f68dd86.a4984","type":"inject","z":"51a64297.ac391c","name":"","topic":"","payload":"C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe (Add-Type '[DllImport(\\\"user32.dll\\\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":166,"y":176,"wires":[["fbb8e3cb.6fbd6","dcce3dc7.7d5bb"]]},{"id":"6c3ffb94.b865a4","type":"debug","z":"51a64297.ac391c","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":682,"y":176,"wires":[]}]

Thank you! Just have tested it. Still no success. Possibly some rights issue (I am admin anyway).
How do you start Node-red on Windows?

I open cmd (just normal one) then type cd .node-red then type node-red

I'm admin as well on Win10 Home
image

So, I tried running Node-red manually from the command line and everything works just fine. So the problem is with the rights when I start NR by scheduler. Will play with startup parameters/methods. Thanks for the clue!

1 Like

Depending on how you've configured that, you may end up running it with SYSTEM permissions rather than user ones. You might also be running Node-RED before the Windows UI is created which might have an impact, I'm not sure.

1 Like