Open hyperh opened 8 years ago
There is a npm package which works great with electron for that! https://www.npmjs.com/package/auto-launch
Yep. auto-launch
works like a charm!
Can you please help me out with step wise commands to create an auto-launch electron app?
I have some way of doing that. Kindly have a look and let me know what to change in this as I'm getting error with npm install electron-prebuilt --save-dev command ?
Please go through this link https://stackoverflow.com/questions/45632502/getting-error-while-executing-npm-install-save-dev-electron-prebuilt?noredirect=1#comment78224205_45632502 to see exactly what is happening when I run this command
STEPS :
mkdir dirname cd dirname npm init npm install electron-prebuilt --save-dev Create index.js npm install electron-packager --save-dev npm start npm run build OR electron-packager . --all
Thank you for your support in advance.
Since this issue was opened, an API has been added to Electron for starting the app at login: https://electron.atom.io/docs/api/app/#appsetloginitemsettingssettings-macos-windows
@zeke thank you, i tried it like this,
const exeName = path.basename(process.execPath);
app.setLoginItemSettings({
openAtLogin: true,
path: process.execPath,
args: [
'--processStart', "${exeName}"
,
'--process-start-args', "--hidden"
]
});
it works for me on windows. but the demo of this api in doc is not correct, the path should be the folder of your app which you want to auto startup.
the demo of this api in doc is not correct, the path should be the folder of your app which you want to auto startup.
@luoboding you mean in the electron/electron docs? If so, would you be able to open a pull request that corrects it?
sorry @zeke , my mistake, i think i misunderstand 'process, execPath' which means the path of app you are running, not the folder, i test the official demo, it works fine. sorry about that.
Question for Windows (NSIS):
What @luoboding is doing only works for me after I have run the app manually at least once. This means that if I'm using perMachine: true
I have to manually open the app once for all users. In our case this means doing this manually for hundreds of users at one of our clients call centers. This is not feasible for us or for our client.
It would seem that all I need to do is to add the app to the Startup menu in the Windows start menu as a part of the installer. Surely this must be possible somehow? Yet has eluded me for some time now. Anybody knows how to pull this off?
@RedDeathAt614 i use NSIS to pack my app, app will be opened automatically when installation is finished.
Thanks @luoboding
If anybody's interested I ended up solving it by setting perMachine: true
and then include an installer.nsh file in the build directory which looks like this:
!macro customInstall
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "CortiRespond" "C:\Program Files\Corti\Corti Respond\Corti Respond.exe"
!macroend
!macro customUnInstall
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "CortiRespond"
!macroend
Hence just setting a key in the registry database to start the app on login and remove it again when the app is uninstalled. This seems to work nicely.
请问如何禁止让项目在安装的时候自动启动?
@zhao2258 you should open a new issue.
@zhao2258 i hope this could help you. https://www.electron.build/configuration/nsis
Sir I want to close my developer tool on click cntrl + shift + I
WebPreferences = new WebPreferences { DevTools = false } I am use this code........but it not work for me
Senhor, quero fechar minha ferramenta de desenvolvedor clicando em cntrl + shift + I
WebPreferences = new WebPreferences { DevTools = false } Estou usando este código ........ mas não funciona para mim
In the index.js file, comment out this line: //mainWindow.webContents.openDevTools();
I'm having some trouble getting my Electron app to start on system startup, does anyone know how this could be done?
Ideally, I could provide users with an ability to toggle this functionality in the Electron main window menu.