Revansiddh
Revansiddh

Reputation: 3072

Electron openItem opens new window of same path

I'm using Electron. When I fire shell.openItem(fullPath to folderA) on button click it opens folder A in widow (correct). But If I fire shell.openItem(fullPath to folderA) again from different button. Instead of bringing already opened folder, it opening folder Ain new window.

Upvotes: 0

Views: 247

Answers (1)

pergy
pergy

Reputation: 5531

Your question is actually an observation. Yes, openItem works that way. (deep inside it calls ShellExecuteEx with "explore" verb option, which works this way)

If you want consecutive calls to use the same window you can use openExternal (which deep inside executes shell with "open" option, which works this way). It will keep the same window open until you don't navigate away

Tested with 6.0.1

const { shell } = require('electron')

setInterval(() => {
  shell.openExternal(__dirname)
}, 5000)

Upvotes: 2

Related Questions