Auto start desktop app at boot time

Hello everyone, may I ask if there is an easy way to auto start a Xojo desktop app at boot time?

I prefer a checkbox “Auto start at boot time” that the user can check/uncheck in the Xojo app that works in both Windows and Mac.
Is this possible?

Thanks in advance for any tips!
Christophe

For Mac see http://www.vdsc.eu/files/helperapp.zip . Be aware that in the Mac App Store, reviewers may frown on such a helper.

For Windows you need to add a string to the following registry key :

My Computer\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run

See http://documentation.xojo.com/index.php/Registry to read and set Windows keys.

on Mac you can use LSSharedFileListMBS in MBS Plugins:
http://monkeybreadsoftware.net/class-lssharedfilelistmbs.shtml

Thank you so much for the help!

The Windows part is working:

Safe button action (preferences 0 or 1 is the saved result of a checkbox):

If Preferences.boot = 1 Then Call AddToStartUp(True) Else Call AddToStartUp(False) End if

Then I added a method AddToStartUp:

[code] Dim Reg As RegistryItem
Reg = New RegistryItem(“HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run”)

Select Case Enabled

Case True 'Add Item
If TargetWin32 Then
Reg.Value( “myAppFilename” ) = SpecialFolder.CurrentWorkingDirectory.AbsolutePath + “myAppFilename” +".exe"
End If
Case False 'Remove Item
If TargetWin32 Then
Reg.Delete(“myAppFilename”)
End If
End Select[/code]

I’ll have a look at the Mac part now…

But the ‘helper app’ method is the only Sandboxed approved method of launching your application on login. They can be a bit funny if you don’t get it quite right, oh heck App Reviewers can be awkward to begin with :wink:

I never wanted to discourage the OP for using that method, but I still have an app rejected because the idiot reviewer still thinks my app spawns a process without the user consent. So on one hand it is the only approved method, and on the other hand the cretin at the door says it’s not kosher…

Was your application launching the process? IRC, you’re not meant to launch the helper app, simply use the security API to register it, then the OS launches the helper app at startup, which in turn launches your main application. It’s all a bit backwards, but it’s what we got.

That is what is done. Yet the stupid dog keeps talking about the app spawning a process after the app has quit :

[code]2.23

The app spawns a process that continues running after the user quits the app, without first obtaining user consent.

The spawned process is /Applications/myapp.app/Contents/Library/LoginItems/Helper.app/Contents/MacOS/Helper.[/code]

I am a bit too furious to do anything about it right now. I will have to calm down before attempting another run around.

From their report, it does seem like the helper application is running, when it technically it shouldn’t. Can you verify this using Activity monitor? If you’d like, I can take a look at the application in a couple of days for you.

You know what ? I just checked in Terminal with PS aux and sure enough, the helper is still running. Valdemar simply forgot to quit his helper…

The reviewer was right after all…

On open the Helper application should follow this logic.

If not mainApplication.running then if mainApplication.open = failed then display a message or debug that it failed to launch the application. end if end if Quit

Glad I was able to help you track this down :slight_smile:

Thank you Sam :slight_smile:

No worries man

Oh… I’ve forgot to correct this point in sample code… sorry for that. I’ll made change.

Great. Thank you.

[quote=132394:@Michel Bujardet]For Mac see http://www.vdsc.eu/files/helperapp.zip . Be aware that in the Mac App Store, reviewers may frown on such a helper.

For Windows you need to add a string to the following registry key :

My Computer\\HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run

See http://documentation.xojo.com/index.php/Registry to read and set Windows keys.[/quote]

the link does not work anymore

i want to have the abilities to start the desktop app or maybe a console app

It appears the technique used then no longer works under Sierra.

I have not worked on that recently, just discovered it did not wrk under Sierra anymore.

I know Christian has something, or you can instruct the user to set the app to start with the system.

For a console program, launchd could work.

I think there may be a problem with Valdemar’s solution under Sierra, Christophe was able to get it to work when using the solution shared in this post.

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