electron-squirrel-startup icon indicating copy to clipboard operation
electron-squirrel-startup copied to clipboard

No shortcut when using "requested-execution-level": "requireAdministrator"

Open tymmesyde opened this issue 6 years ago • 5 comments

I'm using forge and I need to request admin rights for my app but when i do that, there no shortcut created on the Desktop. When i remove requested-execution-level from my package.json, it works. What should I do ?

"forge": {
      "packagerConfig": {
        "name": "MyApp",
        "win32metadata": {
          "requested-execution-level": "requireAdministrator"
        }
      },

tymmesyde avatar Apr 06 '19 22:04 tymmesyde

Same here. Pretty wired.

gogomarine avatar Aug 27 '19 22:08 gogomarine

I just resolve this problem by handling squirrel event: --squirrel-firstrun, based on project electron-squirrel-startup

You can check my code below. In my case I just quit immediately after create shortcut on firstrun.

var path = require('path');
var spawn = require('child_process').spawn;
var app = require('electron').app;

var run = function(args, done) {
  var updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
  // debug('Spawning `%s` with args `%s`', updateExe, args);
  spawn(updateExe, args, {
    detached: true
  }).on('close', done);
};

var check = function() {
  if (process.platform === 'win32') {
    var cmd = process.argv[1];
    // debug('processing squirrel command `%s`', cmd);
    var target = path.basename(process.execPath);

    if (cmd === '--squirrel-firstrun') {
      run(['--createShortcut=' + target + ''], app.quit);
      return true;
    }

    if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
      run(['--createShortcut=' + target + ''], app.quit);
      return true;
    }
    if (cmd === '--squirrel-uninstall') {
      run(['--removeShortcut=' + target + ''], app.quit);
      return true;
    }
    if (cmd === '--squirrel-obsolete') {
      app.quit();
      return true;
    }
    
  }
  return false;
};

module.exports = check();

gogomarine avatar Aug 27 '19 22:08 gogomarine

Hey thanks for the hint I'd like to do the same, but if my app declares "requested-execution-level": "requireAdministrator" No Squirel hook is being called (so I don't get a --squirrel-uninstall for ex) Did you found a solution for this ?

hivenet-adnanetellou avatar Jul 08 '22 10:07 hivenet-adnanetellou

Same here, any update?

deleonjulio avatar Jun 20 '24 03:06 deleonjulio

Same here, any update?

I am also facing the same issue, and it seems there is no solution yet.

MrAhmedElkady avatar Sep 25 '24 22:09 MrAhmedElkady