# Its posible open a program from node-red in Windows?

**URL:** <https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734>\
**Category:** General\
**Created:** [15 February 2020 02:12 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734 "2020-02-15T02:12:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nxito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nxito/32/88293_2.png) [@Nxito](https://discourse.nodered.org/u/Nxito)\
**Post date:** [15 February 2020 02:12 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734/1 "2020-02-15T02:12:18Z")

</div>

Is it possible to open a cmd terminal from node-Red on the local computer?  
I wanted to open a program like ".exe" or ".jpg" from node-red. I don't know if I'm doing something wrong, but they start in the background according to the task manager

The following flow shows some tests but the images show the cmd in the background,

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/f/6f751f13a21010383e5122cfc2c054e0e537a1a5.png)  
What's more, they don't close alone when changing the exec

```auto
[{"id":"e84603ae.338ce","type":"exec","z":"59ec00ab.cbf41","command":"start cmd","addpay":false,"append":"","useSpawn":"true","timer":"10","oldrc":false,"name":"","x":420,"y":140,"wires":[["a6c69679.389088"],["e1b9cd5e.9145f"],["d577fd24.3b93"]]},{"id":"a6c69679.389088","type":"debug","z":"59ec00ab.cbf41","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":120,"wires":[]},{"id":"e1b9cd5e.9145f","type":"debug","z":"59ec00ab.cbf41","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":140,"wires":[]},{"id":"d577fd24.3b93","type":"debug","z":"59ec00ab.cbf41","name":"3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":160,"wires":[]},{"id":"d84974f0.390708","type":"function","z":"59ec00ab.cbf41","name":"","func":"const cp = global.get('child');\n\ncp.spawn('cmd', ['/C', 'start cmd.exe']);","outputs":1,"noerr":0,"x":350,"y":240,"wires":[["40580d5.b2a06f4"]]},{"id":"72ef7328.e481cc","type":"inject","z":"59ec00ab.cbf41","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":140,"wires":[["e84603ae.338ce"]]},{"id":"2ad69a04.951cb6","type":"inject","z":"59ec00ab.cbf41","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":240,"wires":[["d84974f0.390708"]]},{"id":"40580d5.b2a06f4","type":"debug","z":"59ec00ab.cbf41","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":490,"y":240,"wires":[]}]

```

---

<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:** [15 February 2020 15:54 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734/2 "2020-02-15T15:54:33Z")

</div>

> [@Nxito](#):
>
> Is it possible to open a cmd terminal from node-Red on the local computer?

As long as you mean "local to the computer running Node-RED" - then certainly. I do that all the time.

I think that by using `start cmd` you are probably throwing the command into a background process from which it isn't returning?

You don't really need `start cmd` nor even `start` unless you want to start a detached process. `start https://bbc.co.uk` for example should start up a browser window and return immediately. (I think, not tested).

You might need to use `cmd` if you're PC is set to use PowerShell by default instead of cmd.exe or if you need to run a script file that _doesn't_ end in `.cmd` or `.bat`.

---

<div class="post-metadata">

**Author:** ![Nxito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nxito/32/88293_2.png) [@Nxito](https://discourse.nodered.org/u/Nxito)\
**Post date:** [15 February 2020 16:26 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734/3 "2020-02-15T16:26:28Z")

</div>

Well, it seems that it sends me the process to a background process

If I start it directly in CMD, each one of the commands that I put works well, but if I use the node-red exec, it starts it in the background

---

<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:** [15 February 2020 16:27 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734/4 "2020-02-15T16:27:07Z")

</div>

What is it that you are trying to run?

---

<div class="post-metadata">

**Author:** ![Nxito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nxito/32/88293_2.png) [@Nxito](https://discourse.nodered.org/u/Nxito)\
**Post date:** [15 February 2020 16:27 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734/5 "2020-02-15T16:27:52Z")

</div>

OK, its because I use nssm as a windows service,  
if I start node-red from cmd the commands and the exec node works correctly

---

<div class="post-metadata">

**Author:** ![Nxito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nxito/32/88293_2.png) [@Nxito](https://discourse.nodered.org/u/Nxito)\
**Post date:** [15 February 2020 16:29 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734/6 "2020-02-15T16:29:02Z")

</div>

i was trying to open any aplication from exec node like i do on cmd 😅

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 February 2020 16:29 UTC](https://discourse.nodered.org/t/its-posible-open-a-program-from-node-red-in-windows/21734/7 "2020-02-29T16:29:05Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
