teamwork / node-auto-launch Goto Github PK
View Code? Open in Web Editor NEWLaunch applications or executables at login (Mac, Windows, and Linux)
License: MIT License
Launch applications or executables at login (Mac, Windows, and Linux)
License: MIT License
Welcome to Electron
To run your app with Electron, execute the following command under your Console (or Terminal):
path_to_generated path-to-your-app
The path-to-your-app should be the path to your own Electron app, you can read the quick start guide in Electron's docs on how to write one.
Or you can just drag your app here to run it:
node -v
): 6.9.0node-auto-launch - latest
OS - macOS/Linux
I'm using this in an electron app here. It successfully launches the app on system startup but the isHidden
option is not working and it doesn't hide the app even on setting it to true. Here is the relevant code -
https://github.com/zulip/zulip-electron/blob/hidden-on-startup/app/main/startup.js
https://github.com/zulip/zulip-electron/blob/80c37fabb8bf05521c4df47552f82bcd3d41db5d/app/renderer/js/components/webview.js#L73
@adam-lynch let me know if I'm doing anything wrong here.
The install location of the .exe for Windows changes as you update your app when you use Squirrel.Windows (see https://github.com/Squirrel/Squirrel.Windows/blob/master/docs/using/install-process.md#install-location).
When you call the enable
command, auto-launch creates a registry key using the path to the current version, but this does not get updated as you deploy newer versions of your app thru Squirrel and electron's auto-update.
A possible workaround is to listen to the --squirrel-updated
event and call the enable
command again, so the registry key gets recreated.
I am wondering if I am missing something or if there is a better workaround.
node -v
): v7.0.0var axareminderLauncher = new AutoLaunch({
name: 'AxaReminder',
isHidden: true,
});
The autostart file created is for electron executable and not the electron app.
This is the options given.
var axareminderLauncher = new AutoLaunch({
name: 'AxaReminder',
isHidden: true,
});
Even though the name is given, this is the file created.
Type=Application
Version=1.0
Name=electron
Comment=electronstartup script
Exec=/usr/lib/node_modules/electron/dist/electron --hidden
StartupNotify=false
Issues:
Hey, thanks for developing this module!
It works fine, except one thing:
I build my node-webkit application for windows and os x (currently developing on os x) with nw-builder. Running the builded package on os x works fine, except on windows the module 'auto-launch' can't be found.
The module is installed via npm. Is there anything I need to configure specifically for windows?
Hi there I met a issue that my Application shows Unix executable
instead of Application
in Users & Groups
.
Therefore, when I login my Mac, a terminal window would open and shows
Last login: Mon Jul 24 10:20:14 on ttys000
~ /Applications/appName.app/Contents/MacOS/appName ; exit;
/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 3
/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 4
/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 5
/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 6
Once I stop the process, the application would quit.
and there is how I package the application:
"build": "concurrently \"npm run build-main\" \"npm run build-renderer\"",
build-main": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.main.prod.js --colors",
"build-renderer": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.prod.js --colors",
"package": "npm run build && build --publish never",
Is there anything wrong with my code? Or is it how it supposed to be that way?
node -v
):Hi I was trying to auto-launch an app as with this simple script as follows
but I got a problem the app didnt start,
when I use the name micrefat.exe in the path option like this :
any proccess is created whit the name 'minecraft' at the task administrations' tab startup,
but when I used it in this way
it does create a minecrafst.exe at the task-admininstration' tab startup (you can see that at the first screenshoot), the problem is when i restart the computer, nothing happen, Im my doubt is , this little detail about the name of the path file could afecting the startup of the app?
ty guys cheese
regKey = new Winreg
hive: Winreg.HKCU
key: '\\Software\\Microsoft\\Windows\\CurrentVersion\\Run'
I am currently using electron-packager to get convert my electron app to executable. It uses asar to pack all the node modules but auto-launch module is not packed by asar. When I unpack the asar and then put auto-launch into the node-modules and then packing it works fine. Does anyone else have the same problem ?
verify steps:
npm install [email protected]
open ./node_modules/auto-launch
only 3 files in the package directory: LICENSE.md、package.json、README.md。dist folder lost.
This issue is coming when i restart my system and app throw error.
Mac 10.11.6
node 5.8.0
auto-launch 5.0.0
Error: Command failed: osascript -e ' tell application "System Events" to set isUIScriptingEnabled to UI elements enabled
if isUIScriptingEnabled = false then
return false
end if
return true'
68:87: execution error: System Events got an error: AppleEvent timed out. (-1712)
node -v
): 6.11.5{"name": "my-desktop"}
The generated .desktop
file in ~/.config/autostart
looks like the following
[Desktop Entry]
Type=Application
Version=1.0
Name=my-desktop
Comment=my-desktopstartup script
Exec=/opt/My Desktop/my-desktop
StartupNotify=false
Terminal=false
It would work with the space being escaped (Exec=/opt/My\ Desktop/my-desktop
), or the complete path put within quotes (Exec="/opt/My Desktop/my-desktop"
). At least that is what I've tested on my system (Ubuntu 16.04) and worked. It did work on OSX and Windows though.
node -v
): v6.10.0Once I create auto-launch for my application it fails with the next error:
[0608/100331.289731:FATAL:chrome_main_delegate.cc(783)] Check failed: command_line.HasSwitch(switches::kProcessType) && !process_type.empty(). Helper application requires --type.
0 nwjs Framework 0x000000010c382eb3 _ZN2v88UnlockerD1Ev + 15202595
1 nwjs Framework 0x000000010c39c037 _ZN2v88UnlockerD1Ev + 15305383
2 nwjs Framework 0x000000010aaa7683 ChromeMain + 3539
3 nwjs Framework 0x000000010aaa7794 ChromeMain + 3812
4 nwjs Framework 0x000000010bfb8d62 _ZN2v88UnlockerD1Ev + 11229138
5 nwjs Framework 0x000000010bfb83be _ZN2v88UnlockerD1Ev + 11226670
6 nwjs Framework 0x000000010aaa68fb ChromeMain + 75
7 nwjs Helper 0x000000010aa6ddca main + 522
8 libdyld.dylib 0x00007fffb2cdf235 start + 1
And the process exists.
The command that is being invoked with AppleScript or with Launch agent is:
"Alertsite Desktop Proxy.app/Contents/Versions/57.0.2987.98/nwjs Helper.app/Contents/MacOS/nwjs Helper"
If however the command were:
"Alertsite Desktop Proxy.app/Contents/MacOS/nwjs"
It would work like a charm. Am I doing something wrong ?
Thanks a lot in advance.
I've tried setting isHidden to both true and false but neither works.
I'm guessing that calling the show()
method on the main electron window is what's causing this behavior. How do I check that the app has launched at startup to avoid showing the main window?
Promise = require('es6-promise').Promise;
in dist/index.js
appLauncher.enable()
My electron is v1.3.3
Thanks.
Dumb question... can the node-auto-launch package autolaunch a nodejs script?
node -v
):const launcher = new AutoLaunch({
name: result.productName,
path: 'C:\\Program Files\\test\\service\\6.0.177\\test.exe',
isHidden: true
});
try {
await launcher.enable();
log.info(MODULE_NAME, `auto-launch ${result.productName} successfully!`);
} catch (error) {
log.error(MODULE_NAME, `auto-launch ${result.productName} failed! ${error}`);
}```
I also tried to remove `path` but it's the same result
I'm building an Electron app, and I want do different logic between auto-launch
(launch by system) and manually-launch
(click app icon by user). Is there anyway to do that?
node -v
): 6.5.0The app does not launch hidden on Windows 7. I am running with electron-react-boilerplate, which builds with electron-builder 8.5.3
How does this package interact with window.show() in Electron?
According to #34 , if the given path is the path of inner binary, it will be replace to app directory itself.
It may should graceful information in Login Item Preferences.
However, it breaks with LaunchAgent, because LaunchAgent needs inner binary path.
Currently auto-launch
will add/delete a registry key to add it to the startup list. WIndows also seems to remember what the status that was set between adding/removing from the startup list which probably means that it is a separate registry key entry somewhere else.
Can we change the startup status to Enabled
/Disabled
if the key already exists?
API-wise, the default for the enable
/disable
methods would probably be setting the status if it already exists, and then pass a "hard" option in to delete it from the startup list.
// Set the status to `Enabled` if it already exists
// Otherwise create the entry
autoLaunch.enable();
// Set the status to `Disabled`
autoLaunch.disable();
// Remove from startup list
autoLaunch.disable(true);
Using windows 10, nw.js 0.12.3 running as administrator.
Looked at the source:
disable: function(opts, cb) {
return regKey.remove(opts.appName, cb);
}
So its supposed to remove the key in regedit but it does not.
I can get corrent isEnabled() result for the first time. But when runing isEnabled() in a menu click function it always returns "false". And when I print loginItems gotten from apple script, it will be "undefined". I think the root cause is from "applescript" package.
We're going to use plain JavaScript in this repository from now on. Why?
So the existing CoffeeScript needs to be converted to JavaScript. Nothing too fancy, we don't want to have to introduce babel or require users to have Node 8 as a minimum or anything like that.
In doing this, gulp could be removed too but the tests need to still be runnable via npm test
.
We've neglected this project a little bit. Apologies.
Background: I moved into another project within Teamwork which hasn't any desktop apps and the Teamwork Chat team (@4ver, etc.) have had a lot on their plate.
We're going to fix this. We're going to allocate dev time each month or something like that to keep a better eye on the project.
It's also really important that we get some outside contributors as well though. So if anyone can help out in these areas, it would be much appreciated:
Feel free to go ahead and do any of those or write to us (in an issue, email, etc.) if you like.
These are some possible improvements that come to mind right now:
good first issue
and help wanted
.node -v
):Here is a minimal example that produces the error:
var AutoLaunch = require('auto-launch');
After installing [email protected], I am unable to require
the module. Each time I run, I get the following error:
module.js:471
throw err;
^
Error: Cannot find module 'auto-launch'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/benj/Projects/test/index.js:1:80)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
Upon further investigation, I can see that node_modules/auto-launch has no dist folder, nor does it have any JavaScript files of any kind. It looks as if the files were missing from the published package. This does not occur on version 5.0.1.
Does it work with snappy packages on Linux?
Target "snap".
Hi,
I have implemented auto launch and it works perfectly at windows and linux, but, at osx the terminal opens and if I close it, the app is terminated.
Follow the code below.
var AutoLaunch = require('auto-launch');
var appLauncher = new AutoLaunch({
'name': appName
});
appLauncher.isEnabled().then((enabled) => {
if (enabled) return;
return appLauncher.enable()
}).then((err) => {});
Are there any missing configurations?
The target platform(s) the problem occurs on (Linux, Mac, Mac App Store, and or Windows): Windows 8.1
Node version (run node -v
): 6.3.0
auto-launch version: 5.0.1
The options you're passing to auto-launch: var AutoLaunch = require("auto-launch");
var appLauncher = new AutoLaunch({
name: "Trampoline"
});
Are you using NW.js or Electron? Electron
Can you reproduce this with a simple Hello World example app? haven't tried yet
If needs be, would you be able to provide us with a simple app (as simple as possible) which reproduces the problem? will prepare one
The issue is, that calling appLauncher.enable() creates registry entry pointing to executable path. It documentation there is info, that squirrel should be detected and path to Update.exe should be set. Is it true? What should I set, that auto-launch detect squirrel?
Additionaly, if I set name and path (calculated path do the Update.exe --processStart trampoline.exe) i get such entry in registry: Update.exe --processStart trampoline, but the name is set to Trampoline... It seems to be ignored and taken from appPath with removing ending .exe...
EDIT: it cannot work, as paths are set in fixOpts function, that sets for windows invalid path and entry name.
With the registry approach, I'm not sure of a way to support isHidden
. But could you append it to the launch path as a command-line argument? Something like this:
if isHidden
regKey.set opts.appName, Winreg.REG_SZ, "#{opts.appPath} -hidden", cb
else
# Same as before
That way, individual apps could parse the argument on their end to support it.
It would be great if there was an additional option to add --
prefixed arguments to the start-up file (at least the Linux .desktop file). As an example, I use Wire Desktopm, which can be launched minimized by passing the --startup
flag to the wire
command, however there is no option to add --startup
to the desktop file generated by auto-launch. Thanks!
node -v
): 6.10.0I notice that the plist is created with the <key>RunAtLoad</key>
whose value is true
.
Is there any option to set <key>KeepAlive</key>
to true
also?
something like this -
mac: {
useLaunchAgent:true,
keepAlive: true
}
Add toggle
method for easy enable/disable. This makes it easy to set based based on a variable.
var somebool;
autoLauncher[(somebool ? 'enable' : 'disable')](function(err) {
console.log(err);
});
// or
(somebool ? autoLauncher.enable : autoLauncher.disable).bind(autoLauncher)(function(err){
console.log(err);
});
var somebool;
autoLauncher.toggle(somebool, function(err) {
console.log(err);
});
I'm working on an Electron app where, in development, the appName
is simply Electron
rather than Electron.app
. On OS X, this is a problem because the fixOpts()
method "adjusts" the appName for display by lopping off .app
even if it doesn't exist in the name.
It would be nice if the method would at least ensure that the appName
ends with .app
before stripping those last four.
Platform: Windows 10 x64
Node v6.11.2
auto-launch v5.0.1
Using electron, and after installation i run a form which user has to enter configuration for the application, there the auto-launch should work, the problem is that the installation wizard (thus the configuration form) runs under a specific user, and the main application (which i need to set the auto launch for) runs under different user.
And because of this the auto launch functionality wont work because the registry change is under HKCU, to resolve this there must be a parameter in the construct whether the auto launch should be for all users or not, and this boolean value will decide whether to make the change in HKCU or HKLM.
So I've run the example and I now have an entry in this part of regedit https://github.com/Teamwork/node-auto-launch/blob/master/src/AutoLaunchWindows.coffee#L5
but it doesn't start on login for some reason. Is there anyway to debug this? The .exe is set to run as administrator, could this be blocking it's auto start?
See #17 (comment) as an example.
I enabled auto-launch, then I delete login item in my OS, how my app can detect if login item was deleted from system.
node -v
): 8.10.0var autoLauncher = new AutoLaunch({
name: 'Name with space',
});
If I pass value for option name
in AutoLaunch object which has whitespace, the execute path in .desktop file will not be escaped.
Value: Name with space
Expected execute path: /opt/Name\ with\ space/app
Actual execute path: /opt/Name with space/app
(missing \
to escape whitespace)
I would like to be able to make whether the application is hidden on auto launch user settable, but the current API doesn't make that feasible. There is no way to easily tell if the currently enabled auto-launch is configured to launch hidden, or to change the setting for an AutoLaunch
instance.
If someone uses this module in their app (e.g. NW.js or Electron app), it should not cause the app to be rejected.
Anyone has any experience as to how to make auto-launch work on a Mac App Store Electron build?
All system-level functionality is locked by default, so it will probably need to be enabled in the entitlements files used to sign the build. I've tried adding temporary exceptions like below, but it doesn't seem to work.
<key>com.apple.security.temporary-exception.apple-events</key>
<array>
<string>com.apple.systemevents</string>
</array>
node -v
):My application doesn't start when Windows is restarted and a
registry entry under \HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run is not created.
Hello There,
I am trying to open a simple electron application on startup. Below is my code, i think i am doing something wrong, can you please help. Please pardon me if i have missed something. Thanks.
'use strict';
var AutoLaunch = require('auto-launch');
var appLauncher = new AutoLaunch({
name: 'My NW.js or Electron app'
});
appLauncher.isEnabled(function(enabled){
if(enabled) return;
appLauncher.enable(function(err){
});
});
// Module to control application life.
const app = electron.app;
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 1620, height: 740});
// and load the index.html of the app.
mainWindow.loadURL('http://orcatv.net/pace/nyc720.php');
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
node -v
): 8.10Now my program can auto start, but the window still show after login, even I already set isHidden to true.
I try to see the nw.App.argv array, but not found any about hidden information.
How can I do to handle the hidden in MacOS?
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.