# Exec node (shellexecute)

**URL:** https://discourse.nodered.org/t/exec-node-shellexecute/22607
**Category:** General
**Created:** [4 March 2020 09:28 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607 "2020-03-04T09:28:11Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![bibou](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@bibou](https://discourse.nodered.org/u/bibou)
#### Post date: [4 March 2020 09:28 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/1 "2020-03-04T09:28:11Z")

</div>

Hello everybody, I want to ask you someting. I want to use "Exec" node and use the command line "shellexecute' but I don't know how to do that. The aim of that is to open Chrome and open a http inside. Someone know how ? Thank you

---

<div class="post-metadata">

### Author: ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)
#### Post date: [4 March 2020 09:41 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/2 "2020-03-04T09:41:53Z")

</div>

That topic came up several times now. Maybe you can find some pointers there.

> [@Open a web browser with EXEC node](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163):
>
> Hello, I'm attempting to use Node-Red to open a web browser UI on the Windows 10 PC which hosts Node-Red. I've tried using the EXEC node in spawn mode for this purpose with the command powershell start chrome, however chrome launches as 7 background processes rather than a chrome application with a desktop UI (i.e. no browser UI is visible in Windows). Node-Red is running under the admin user account, on a single user PC. My goal is to use Node-Red to open / close Chrome UI, and to control t…

> [@Chrome, web page and move windows](https://discourse.nodered.org/t/chrome-web-page-and-move-windows/21963):
>
> Hello, I have to use node-red for several things: First, I have to succeed in launching chrome, I used "Exec" function for this Second, and this is where I block, I have to open a web page on it. And lately, I have to be able to move the window to another screen if it detects a screen and put it in full screen. All this to do on node-red and everything has to be done automaticly.

---

<div class="post-metadata">

### Author: ![bibou](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@bibou](https://discourse.nodered.org/u/bibou)
#### Post date: [4 March 2020 09:45 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/3 "2020-03-04T09:45:22Z")

</div>

But these topic don't help me to use the command line "shellexectue" and I forgot to tell that Node-red play in background inside a VM.

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [4 March 2020 11:15 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/4 "2020-03-04T11:15:54Z")

</div>

Okay, can you tell me a bit more about this `shellexecute` tool. Where can I find it, for example, to discover more information on how it works. You mention a VM. The browser you’re trying to start, is it on the VM or on the host machine?

---

<div class="post-metadata">

### Author: ![bibou](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@bibou](https://discourse.nodered.org/u/bibou)
#### Post date: [4 March 2020 11:19 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/5 "2020-03-04T11:19:03Z")

</div>

It's not an obligation to use ShellExecute but I want to use something that do the same think, like ShellExecute in AutoIt ([https://www.autoitscript.fr/autoit3/docs/functions/ShellExecute.htm](https://www.autoitscript.fr/autoit3/docs/functions/ShellExecute.htm)) Nod-red start on my VM but I use it on my host machine.

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [4 March 2020 11:37 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/6 "2020-03-04T11:37:36Z")

</div>

Okay, and where do you need the browser to launch? On the host machine too? Just asking this for verification as I have an idea but I’ve to know for certain first. It’s less easy than you might have expected

---

<div class="post-metadata">

### Author: ![bibou](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@bibou](https://discourse.nodered.org/u/bibou)
#### Post date: [4 March 2020 12:43 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/7 "2020-03-04T12:43:38Z")

</div>

Yes on my host macine too, and my VM don't have interface, it's a Linux VM

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [4 March 2020 13:36 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/8 "2020-03-04T13:36:24Z")

</div>

Okay so to summarise:

- Host machine running Windows, version ??? [ShellExecute is part of the Win32 API]
- Host machine running virtual machine(s), including a Linux VM
- Linux VM does not have a desktop environment
- Host machine has Chrome installed  
Goal: have linux VM start Chrome on the host machine to a specific page.

* * *

To get started here, you need to set up a method of communication between your host and your VM. Since the VM is sandboxed, you can't directly execute commands on the host machine. An often picked solution for communication between two systems (that is, in the node-RED community), is MQTT. To do so, you would run an MQTT broker on either the host system or the VM, and have the host machine set up a network interface on/with the VM to communicate. Next step is to have both Node-RED on the VM, and a tool running on the host machine connect to this MQTT broker. From the Node-RED flow, you can send a message with payload to an MQTT-out node. Then on the host machine, the tool you'd use there subscribes to the topic that payload is send out to, and receives the payload.

An example of a tool that can do this is listed on the [Awesome MQTT](https://github.com/hobbyquaker/awesome-mqtt) page: [WinThing](https://github.com/msiedlarek/winthing). It requires Java, but make sure to check the version. It's no longer in active development, and newer versions will cause it to fail. Another one listed there is [mqttpc](https://github.com/hobbyquaker/mqttpc), although it is unclear if it supports Windows. The libraries underneath that it depends on are the same used for the regular exec node in Node-RED, so my guess is that it is supported, although not documented.

Now, when you've reached that stage, look back to those topics linked above by @kuema to see if you can figure out the rest yourself.  
One more thing before I forget, here's a good getting started guide to help you understand MQTT/what you're doing: [https://www.hivemq.com/mqtt-essentials/](https://www.hivemq.com/mqtt-essentials/)

---

<div class="post-metadata">

### Author: ![bibou](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@bibou](https://discourse.nodered.org/u/bibou)
#### Post date: [4 March 2020 13:42 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/9 "2020-03-04T13:42:24Z")

</div>

Windows 10 for my windows, My linux VM and my host machine is connected together. I have an IP that take me my Linux VM. With this IP, I can use it to my host machine to use Node-red

---

<div class="post-metadata">

### Author: ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)
#### Post date: [4 March 2020 13:43 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/10 "2020-03-04T13:43:04Z")

</div>

Sounds like a good idea to run the broker on your linux VM in that case, and connect the host through the broker located there.

---

<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: [4 March 2020 15:18 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/11 "2020-03-04T15:18:19Z")

</div>

Or also run Node-RED on the host 🙂

Then the VM could be allowed to communicate with the host via a single TCPIP Address/Port without the need to run another service.

---

<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: [3 May 2020 15:18 UTC](https://discourse.nodered.org/t/exec-node-shellexecute/22607/12 "2020-05-03T15:18:36Z")

</div>

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