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

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

Open
tymmesyde opened this issue Apr 6, 2019 · 4 comments

Comments

@tymmesyde
Copy link

tymmesyde commented Apr 6, 2019

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"
        }
      },
@gogomarine
Copy link

Same here. Pretty wired.

@gogomarine
Copy link

gogomarine commented Aug 27, 2019

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();

@hivenet-adnanetellou
Copy link

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 ?

@deleonjulio
Copy link

Same here, any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants