Restarting application when computer restarts

I have been requested to add an option to my application that will automatically start the application when the computer is restarted and/or the user logs in. I suspect that this is either not possible to set up from within the application, or would require elevated privileges, etc. Any suggestions? I need this for macOS and Windows (and bonus points for Linux).

On Windows, you can add a link to your application in the startup folder, or set the application up as a service with an automatic start. The user could also do it himself using the Task Manager. (in the startup tab, find the application and right click the mouse. Then, select “Activate”.)

On mac there is login items option:
System Preferences - Users & Groups - Login Items.

Don’t know if Linux distros use the same /etc/rc.d directory or /etc/rc.local file to execute scripts when the machine starts. I don’t use Linux on desktop only little server experience.

On the Mac it’s doable, but it’s a slightly complicated procedure. Go to this page and scroll down to my first post from 1st June 2017.

https://forum.xojo.com/40988-add-app-at-login-items-mas

When you shutdown MacOS, all actually open applications are restarted on reboot excepted Xojo (the IDE). And this is probable from before El Capitan (3 OS major versions away ?). I am quite sure that Windows 10 already have this set of features. Linux ? (I do not know).

Better: the opened documents (and the unsaved documents) are re-opened and displayed… Go figure…

That is far beyond what Paul ask (but it can be what the user(s) are asking).

I was asking that in last March. I do not answer to that, but smiled thinking (“Hey man, did you ask similar kind of question to Microsoft for the Word software you are using everyday ?”). After that, I discovers that the guy have very little knowledge on the computer industry and as end user :wink:

Please check LSSharedFileListMBS class inn MBS Xojo Plugin for adding login item on Mac.
Or better the ServiceManagementModuleMBS module as this example shows.

Another possibility on macOS is to use launch services. User specific ones don’t need elevated privileges to install, but ones that start before a user logs in certainly do.

If you’re curious what such a script looks like in layman’s terms, I suggest downloading the demo of LaunchControl and looking at the ones already on your machine. They can get really sophisticated, but the plist allows for many powerful features as well.

http://www.soma-zone.com/LaunchControl/

Thanks everyone. Some excellent paths to explore.

For Linux… This is my first project in Xojo, AND first time working with Linux so forgive my lack of lingo.

Here are the instructions I now have for myself where “myapp” is the name of my Xojo project and it is in the “share” folder. I put a shortcut on the desktop, then launch it on startup.

Shortcut on desktop
right click on the desktop and create new file with “desktop” extension, e.g. MyApp.desktop. Edit as below
[Desktop Entry]
Name=Stats
Comment=Stats
Icon=/share/myapp/GreenBucket.ico
Exec=/share/myapp/ myapp
Type=Application
Encoding=UTF-8
Terminal=false

To autostart app on bootup:
Go to home folder then CTRL + H to show hidden files
Go to /home/pi/.config/autostart folder
Create a file here called myapp.Desktop
Edit file to have this text in it
[Desktop Entry]
Type=Application]
Name=myapp
Exec=sudo /share/myapp/myapp

[quote=405462:@Dawn McCoy]Here are the instructions I now have for myself where “myapp” is the name of my Xojo project and it is in the “share” folder. I put a shortcut on the desktop, then launch it on startup.
[/quote]

Thanks. That helped a lot. It’s now working on Linux.