# Node-red on Windows exec node issue

**URL:** https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094
**Category:** General
**Tags:** windows
**Created:** [13 December 2019 01:28 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094 "2019-12-13T01:28:12Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![ded\_banzai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ded_banzai/32/13179_2.png) [@ded\_banzai](https://discourse.nodered.org/u/ded_banzai)
#### Post date: [13 December 2019 01:28 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/1 "2019-12-13T01:28:12Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [13 December 2019 09:52 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/2 "2019-12-13T09:52:24Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [13 December 2019 10:22 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/3 "2019-12-13T10:22:02Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ded\_banzai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ded_banzai/32/13179_2.png) [@ded\_banzai](https://discourse.nodered.org/u/ded_banzai)
#### Post date: [13 December 2019 16:02 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/4 "2019-12-13T16:02:48Z")

</div>

`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

---

<div class="post-metadata">

### Author: ![ded\_banzai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ded_banzai/32/13179_2.png) [@ded\_banzai](https://discourse.nodered.org/u/ded_banzai)
#### Post date: [13 December 2019 16:06 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/5 "2019-12-13T16:06:42Z")

</div>

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

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [13 December 2019 16:17 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/6 "2019-12-13T16:17:33Z")

</div>

> [@ded\_banzai](#):
>
> 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)

Worked for me putting the cmd in an inject node

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

### Author: ![ded\_banzai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ded_banzai/32/13179_2.png) [@ded\_banzai](https://discourse.nodered.org/u/ded_banzai)
#### Post date: [13 December 2019 16:35 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/7 "2019-12-13T16:35:05Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [13 December 2019 16:39 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/8 "2019-12-13T16:39:15Z")

</div>

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

I'm admin as well on Win10 Home  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6c2f91117e3c550792cc63b0dff8c8abf0a01c1e.png)

---

<div class="post-metadata">

### Author: ![ded\_banzai](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ded_banzai/32/13179_2.png) [@ded\_banzai](https://discourse.nodered.org/u/ded_banzai)
#### Post date: [13 December 2019 17:29 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/9 "2019-12-13T17:29:54Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [13 December 2019 17:36 UTC](https://discourse.nodered.org/t/node-red-on-windows-exec-node-issue/19094/10 "2019-12-13T17:36:14Z")

</div>

> [@ded\_banzai](#):
>
> when I start NR by scheduler

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.
