Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quitting second instance deletes files in extra resources for portable build #5382

ari5501 opened this issue Oct 30, 2020 · 1 comment


Copy link

@ari5501 ari5501 commented Oct 30, 2020

  • Version: 22.8.0
  • Electron Version: 8.5.1
  • Electron Type (current, beta, nightly): current
  • Target: portable

I am building a portable target on Windows. I need to include some extra files, so my package.json looks like this

"build": {
    "extraResources": [
    "win": {
      "target": "portable"

I found some code on the Electron docs to handle a second instance being opened up. It looks like this

const gotTheLock = app.requestSingleInstanceLock()

if (!gotTheLock) {
} else {
  app.on('second-instance', (event, commandLine, workingDirectory) => {
    // Someone tried to run a second instance, we should focus our window.
    if (myWindow) {
      if (myWindow.isMinimized()) myWindow.restore()

  // Create myWindow, load the rest of the app, etc...
  app.whenReady().then(() => {

The problem I'm encountering is when the second instance of my app quits, it deletes all the files in my resources folder, so extraFiles.js gets deleted. The only thing left is app.asar. It also deletes a good amount of other files in the main directory. Is there any way to get around this?

Copy link

@stale stale bot commented Dec 31, 2020

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.


@stale stale bot added the backlog label Dec 31, 2020
@stale stale bot closed this Jan 9, 2021
mmaietta added a commit to mmaietta/electron-builder that referenced this issue Apr 15, 2021
mmaietta added a commit that referenced this issue Jul 29, 2021
…unch (#6093)

* Allowing boolean flag to `unpackDirName` to utilize `$PLUGINSDIR` (unique to per-app-launch) when set explicitly to `true`. Implements #5764, #5382, #4105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant