# Open a web browser with EXEC node

**URL:** https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163
**Category:** General
**Created:** [24 November 2018 10:59 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163 "2018-11-24T10:59:55Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mike.gofton](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mike.gofton/32/77043_2.png) [@mike.gofton](https://discourse.nodered.org/u/mike.gofton)
#### Post date: [24 November 2018 10:59 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/1 "2018-11-24T10:59:55Z")

</div>

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 the displayed content.  
Any assistance is most appreciated - thanks in advance.

---

<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: [25 November 2018 19:14 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/2 "2018-11-25T19:14:43Z")

</div>

> [@mike.gofton](#):
>
> Node-Red is running under the admin user account

This may be the issue. Are you saying that you are running it from an elevated command or from a different user to the one normally logged in?

As far as I can tell, you should be able to do this fine. I'll check if I have time.

However, don't get your hopes up too far. You do realise that you cannot automate Chrome from powershell, let along Node-RED don't you?

There are however tools that will let you do that such as Selenium. I think some of the headless browser tools also let you create a window as well.

---

<div class="post-metadata">

### Author: ![mike.gofton](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mike.gofton/32/77043_2.png) [@mike.gofton](https://discourse.nodered.org/u/mike.gofton)
#### Post date: [26 November 2018 06:35 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/3 "2018-11-26T06:35:55Z")

</div>

Node-Red is running under the logged in user account, which is also an administrator account.

I was able to successfully use Selenium to launch Chrome using node-red-contrib-selenium-webdriver.  
For comparison purposes, I tried using Node.js Puppeteer via a Function node to launch Chromium. This worked with limited success, as Puppeteer employs asynchronous callbacks which Node-Red doesn't appear to support.  
Sadly, while Selenium works, the web site I was using it with relies on user authentication and this appears to be lost, resulting in a manual login each time.

I still don't understand why the EXEC node won't launch chrome under Win 10. I tried launching VLC (`start vlc`) and observed the same behaviour with the EXEC node, i.e. VLC spawned as a background process without a UI. The same command works successfully when entered to Powershell running under the user account.

I tried using Node-Red running under Raspbian to launch Chromium with no luck. Entering `pi@raspberrypi:~ $ chromium-browser & disown` into a terminal window works , however the same command used in the EXEC node doesn't.  
The following debug messages were received :  
`[11312:11312:1126/164144.443246:ERROR:browser_main_loop.cc(670)] Failed to put Xlib into threaded mode.` and `(chromium-browser:11312): Gtk-WARNING **: cannot open display:`

There's probably an obvious reason related to the use of a child process in the EXEC node, but my software skills are rather limited.

Thanks for your help.

---

<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: [26 November 2018 09:27 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/4 "2018-11-26T09:27:15Z")

</div>

> [@mike.gofton](#):
>
> running under the logged in user account, which is also an administrator account

OK, that is different. Such a user only gets limited access by default, many tasks will generate the protection dialog. Not the same as running Node-RED itself with admin privileges.

> [@mike.gofton](#):
>
> Puppeteer employs asynchronous callbacks which Node-Red doesn't appear to support.

Well, NR is written using JavaScript/NodeJS so in theory, it does support them. However, integration can be a challenge. It might need you to require the library in settings.js as a global variable - you can then make use of it from within a function node. A proper custom node would be better of course but a lot more work.

> [@mike.gofton](#):
>
> understand why the EXEC node won't launch chrome

It would be interesting to try the equivalent call direct from a simple, test, Node.JS app. That would probably show whether it is a Node-RED issue or a Node.JS one.

Also, have you tried starting chrome.exe directly from the EXEC node?

---

<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: [26 November 2018 09:47 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/5 "2018-11-26T09:47:01Z")

</div>

> [@TotallyInformation](#):
>
> have you tried starting chrome.exe directly from the EXEC node?

So, some quick tests.

Under Windows 10, even with PowerShell set as the default shell, the exec node starts a cmd window not a powershell. It is that that is causing the issue.

Change the exec to be the following command (adjusting for the location of your ps1 file):

```auto
powershell -NonInteractive -NoLogo ./data/chrome.ps1

```

That works just fine.

---

<div class="post-metadata">

### Author: ![mike.gofton](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mike.gofton/32/77043_2.png) [@mike.gofton](https://discourse.nodered.org/u/mike.gofton)
#### Post date: [26 November 2018 16:22 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/6 "2018-11-26T16:22:25Z")

</div>

I tried your suggested fix however the problem remained. So I checked in task manager and Node.js was running as a background process owned by SYSTEM. As it turns out, I am launching node-red via the Windows Task Scheduler and I had selected the 'run whether user is logged on or not' button. After changing the node-red task to run only when the user is logged on, and running the task, Node.js appeared as an application owned by the user. Magically I was now able to launch chrome via the EXEC node using the command `path\script.cmd` where script.cmd is `start chrome "https://www.google.com.au"`.  
The lesson here seems to be don't expect Node.js running as a system service to launch applications with a UI.  
Thanks so much for your help.

---

<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: [26 November 2018 16:26 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/7 "2018-11-26T16:26:47Z")

</div>

Which is the same for Linux / Pi - as per your "can't open display" messages above.

---

<div class="post-metadata">

### Author: ![aco7342](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/aco7342/32/649_2.png) [@aco7342](https://discourse.nodered.org/u/aco7342)
#### Post date: [28 November 2018 11:27 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/8 "2018-11-28T11:27:53Z")

</div>

sorry for my poor english.

do you can´t use eletron-node red?  
see: [https://github.com/natcl/electron-node-red](https://github.com/natcl/electron-node-red), [https://www.npmjs.com/package/micro-app-electron-launcher](https://www.npmjs.com/package/micro-app-electron-launcher), [https://poshtools.com/2018/02/05/creating-desktop-app-universal-dashboard-installer-powershell-pro-tools/](https://poshtools.com/2018/02/05/creating-desktop-app-universal-dashboard-installer-powershell-pro-tools/)

---

<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: [28 November 2018 11:49 UTC](https://discourse.nodered.org/t/open-a-web-browser-with-exec-node/5163/9 "2018-11-28T11:49:12Z")

</div>

> [@aco7342](#):
>
> do you can´t use eletron-node red?

There are lots of ways to run Node-RED, it depends on your requirements. Personally I don't use the Electron version as I don't need it. But I tend to run NR manually on my Windows PC as I use it mainly for development and occasional bits-and-pieces so I don't need it running all the time. I have defined some handy scripts in my npm `package.json` file. So I have standard ways of updating and running NR and its nodes.
