electron / packager

Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI
https://npm.im/@electron/packager
BSD 2-Clause "Simplified" License
184 stars 18 forks source link

`app.setLoginItemSettings` works incorrectly while packaged with the environment variable `--win32metadata.requested-execution-level=requireAdministrator` #1366

Open ch1ny opened 2 years ago

ch1ny commented 2 years ago

Preflight Checklist

Issue Details

Behavior

I'm trying to add a feature to my Electron application to make it automatically run after my computer starting up. And this is my source code:

        ipcMain.on('EXCHANGE_OPEN_AT_LOGIN', (evt, openAtLogin) => {
            if (app.isPackaged) {
                app.setLoginItemSettings({
                    openAtLogin,
                });
            }
        });

If I packaged my application with command like this , my application can be successfully self-booted.

electron-packager ./build SduMeeting --platform=win32 --arch=x64 --out ./dist --asar --overwrite

However, to implement certain features, I have to package it with command like this to get administrator privileges.

electron-packager ./build SduMeeting --platform=win32 --arch=x64 --out ./dist --asar --overwrite --win32metadata.requested-execution-level=requireAdministrator

The application packaged in this way cannot be opened automatically.

Additional Information

Excuse me, I'm a college student from a university in China with poor English. I wish my poor presentation wouldn't cause troubles for you.

welcome[bot] commented 2 years ago

šŸ‘‹ 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.

toantt2k commented 10 months ago

Hey man, have you fixed this error yet?

ch1ny commented 10 months ago

Hey man, have you fixed this error yet?

Yes, I have solved this problem by modifying the Windows registry, but I am not sure that my method is appropriate. You can see my code from the link below: https://github.com/ch1ny/SduMeeting/blob/7ed5a51e2eac5716f16f30639455aa3d762b1260/main.js#L363

There may be other, better ways to work it out.

s0ckd3 commented 2 months ago

up