14.8 C
London
Friday, October 20, 2023

launchd – The best way to register some program “at login” for all customers on macOS


I do know I can use “Service Administration” (SMAppManager) for the present person [or do the equivalent action via setup], however it solely registers at login for the present person, however I want my app to register at login for the present person and for all different customers.

do {
    strive SMAppService.mainApp.register()
}
catch {
    print(error)
}

I do know that you should use “RunAlLoad” within the launchd config, however it does not work fairly the best way I would like it to as a result of it truly begins when this system is loaded when loaded by way of launchctl or solely after a reboot.

<?xml model="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="2.0">
<dict>  
    <key>Label</key>
    <string>com.companyname.software</string>
    
    <key>ProgramArguments</key>
    <array>
        <string>/path/to/software</string>
    </array>

    <key>RunAtLoad</key>
    <true/>

</dict>
</plist>

I additionally tried utilizing the “OnDemand” choice with the worth “false”, however then the appliance simply begins all time:

<?xml model="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist model="2.0">
<dict>  
    <key>Label</key>
    <string>com.companyname.software</string>
    
    <key>ProgramArguments</key>
    <array>
        <string>/path/to/software</string>
    </array>

    <key>OnDemand</key>
    <false/>

</dict>
</plist>

Which launchd config file can be utilized for this or how can I do it with “Service Administration” ?

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here