Exec node (shellexecute)

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

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

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.

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?

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) Nod-red start on my VM but I use it on my host machine.

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

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

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 page: 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, 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/

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

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.

Or also run Node-RED on the host :slight_smile:

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

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