autorun an java application when user connect(startup) with windows and osx

Comments

4 comments

  • Avatar
    wojciechka

    Please find an example below that sets the Windows registry Run key (which is responsible for applications started at login) and creates an OS X service with keep alive disabled, which will cause the application to be started on both Windows and OS X at user login.

    It also includes action to perform the uninstallation.

    <postInstallationActionList> <registrySet> <key>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</key> <name>"${installdir}\${project.shortName}.exe"</name> <type>REG_SZ</type> <value>${project.shortName}</value> <ruleList> <platformTest> <type>windows</type> </platformTest> </ruleList> </registrySet> <createOSXService> <groupname></groupname> <keepAlive>0</keepAlive> <program>${installdir}/${project.shortName}.app/Contents/MacOS/installbuilder.sh</program> <programArguments></programArguments> <serviceName>${project.shortName}</serviceName> <username></username> <ruleList> <platformTest> <type>osx</type> </platformTest> </ruleList> </createOSXService> </postInstallationActionList> <postUninstallationActionList> <registryDelete> <key>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</key> <name>${project.shortName}</name> <ruleList> <platformTest> <type>windows</type> </platformTest> </ruleList> </registryDelete> <deleteOSXService> <serviceName>${project.shortName}</serviceName> </deleteOSXService> </postUninstallationActionList>

    0
    Comment actions Permalink
  • Avatar
    devildant

    Hello,

    Thank you. it's work. I analyzed the changes on os x, and I understand how it worked. For windows it's necessary to manage the version (32 or 64)

    i custom the solution :

    <postInstallationActionList>
    <registrySet>
        <breakpoint>1</breakpoint>
        <key>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</key>
        <name>HOMESTATION</name>
        <type>REG_SZ</type>
        <value>${installdir}/${java_launcher_jar}</value>
        <ruleList>
            <platformTest>
                <type>windows</type>
            </platformTest>
        </ruleList>
    </registrySet>
    
    <registrySet>
        <breakpoint>1</breakpoint>
        <key>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run</key>
        <name>HOMESTATION</name>
        <type>REG_SZ</type>
        <value>C:\Program Files (x86)\Homestation-1.0\Homestation-launcher.exe</value>
        <wowMode>64</wowMode>
        <ruleList>
            <platformTest>
                <type>windows-x64</type>
            </platformTest>
        </ruleList>
    </registrySet>
    
    <writeFile>
        <encoding>utf-8</encoding>
        <path>${system_temp_directory}/${project.shortName}.plist</path>
        <text>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
                &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
                &lt;plist version="1.0"&gt;
                    &lt;dict&gt;
                        &lt;key&gt;KeepAlive&lt;/key&gt;
                        &lt;false/&gt;
                        &lt;key&gt;AbandonProcessGroup&lt;/key&gt;
                        &lt;true/&gt;
                        &lt;key&gt;Label&lt;/key&gt;
                        &lt;string&gt;Homestation&lt;/string&gt;
                        &lt;key&gt;ProgramArguments&lt;/key&gt;
                        &lt;array&gt;&lt;string&gt;${installdir}/${java_launcher_binary_name}/Contents/MacOS/installbuilder.sh&lt;/string&gt;
    &lt;/array&gt;
                        &lt;key&gt;RunAtLoad&lt;/key&gt;
                        &lt;true/&gt;
                    &lt;/dict&gt;
                &lt;/plist&gt;</text>
    </writeFile>
    <copyFile>
        <destination>/Library/LaunchAgents/${project.shortName}.plist</destination>
        <origin>${system_temp_directory}/${project.shortName}.plist</origin>
    </copyFile></postInstallationActionList>
    

    I manually generated the plist file (os x service) to change the directory so that my program is launched at the opening session of all the users. and for add the option: AbandonProcessGroup (cf : doc apple)

    best regards

    0
    Comment actions Permalink
  • Avatar
    devildant

    Hello,

    I also have another question, is there something similar for Linux plateform?

    Best regards

    0
    Comment actions Permalink
  • Avatar
    devildant

    hello,

    thank you for this response. I'll watch the XDG.

    0
    Comment actions Permalink

Please sign in to leave a comment.