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

--win32metadata.requested-execution-level=requireAdministrator Can't create shortcut desktop app when install app after build. #1560

Open
PhiHoangNguyen13799 opened this issue Sep 11, 2023 · 1 comment
Labels

Comments

@PhiHoangNguyen13799
Copy link

STEP TO REPRODUCE

  1. Build by electron-packager with cmd --win32metadata.requested-execution-level=requireAdministrator Miniique
    "scripts": {
    "build-prod": "electron-packager src --platform=win32 --arch=x64 --icon=icon.ico Miniique prod && node build.js",
    "build-stag": "electron-packager src --platform=win32 --arch=x64 --icon=icon.ico Miniique stag && node build.js",
    "build-dev": "electron-packager src --platform=win32 --arch=x64 --icon=icon.ico --win32metadata.requested-execution-level=requireAdministrator Miniique dev && node build.js"
    }

  2. When install app After build

image

It will show popup to request admin permission from your computer.
3. After choose yes for the request admin permission.
App run, and all the feature work, but it can't create shortcut in desktop.

(May be admin don't have permission to create shortcut in desktop)

If i don't add --win32metadata.requested-execution-level=requireAdministrator . And do all the same step. App work perfectly. But some case we need to write or read file in computer. We need admin permission.

Code create shortcut may be helpful

const squirrelEvent = process.argv[1];
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':

  // Install desktop and start menu shortcuts
  spawnUpdate(['--createShortcut', shortcutName]);

  setTimeout(application.quit, 1000);
  return true;

case '--squirrel-uninstall':
  // --squirrel-updated handlers

  // Remove desktop and start menu shortcuts
  spawnUpdate(['--removeShortcut', shortcutName]);

  setTimeout(application.quit, 1000);
  return true;

case '--squirrel-obsolete':
  // This is called on the outgoing version of your app before
  // we update to the new version - it's the opposite of
  // --squirrel-updated

  application.quit();
  return true;

}
};

@welcome
Copy link

welcome bot commented Sep 11, 2023

👋 Thanks for opening your first issue here! If you have a question about using Electron Packager, read the support docs. If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

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

No branches or pull requests

1 participant