On 22 Aug 2006, at 18:10, Arnaud Nicolet wrote:

Hi,

I've made 2 applications. The main app and a "server" app (this is a service app which keeps running while the computer is working).

I would like to have an option, in the main app, so that it can add the "server" app to the list of processes launched at startup (when we see "Welcome to MacOS X").
I know I have to ask for the admin's password, that's not a problem.

Can this be done?

I haven't done it myself from a REALbasic app, but these are the things you need to do for a startup item:

- Add a line to /etc/hostconfig like MYAPP =-YES- (you'll need admin privileges for this) - Add a folder to /Library/StartupItems e.g. MyApp, look at an existing one for chmod privileges - In that folder add a file "StartupParameters.plist", it should look like this:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http:// www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Description</key>
        <string>MyApp</string>
        <key>OrderPreference</key>
        <string>None</string>
        <key>Provides</key>
        <array>
                <string>MYAPP</string>
        </array>
        <key>Uses</key>
        <array>
                <string>Network</string>
                <string>Resolver</string>
        </array>
        </dict>
</plist>

- Add a second file to the folder named after what you put in hostconfig, it should look like this:

if [ -z $1 ] ; then
        echo "Usage: $0 [start|stop|restart] "
        exit 1
fi

# Source the common setup functions for startup scripts
test -r /etc/rc.common || exit 1
. /etc/rc.common


SCRIPT="/shellpathtoapp"

StartService ()
{
        if [ "${MYAPP:=-NO-}" = "-YES-" ] ; then
                ConsoleMessage "Starting MyApp server"
                $SCRIPT start > /dev/null 2>&1
        fi
}

StopService ()
{
        ConsoleMessage "Stopping MyApp server"
        $SCRIPT stop > /dev/null 2>&1
}

RestartService ()
{
        ConsoleMessage "Restarting MyApp server"
        $SCRIPT restart > /dev/null 2>&1
}

if test -x $SCRIPT ; then
        RunService "$1"
else
        ConsoleMessage "Could not find MyApp startup script!"
fi

- Your application should listen to a start/stop/restart command.

Instead of doing all of this from your application, you'll be better off creating a package that does all this. The application to create packages is included in the Developer Tools from MacOS X. It's a bit of a pain to get familiar with, but it will save you more trouble than doing it from REALbasic.


Best regards

Peter De Berdt

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to