Search code examples
javawindowswixwindows-installerjpackage

Post-installation script in Jpackage for Windows


I have been exploring jpackage to create installers for an app and I have already created installers for both MacOs and Linux. Now that I'm trying to create an installer for Windows I came across a problem, while MacOs and Linux both offer the possibility of having a post installation script Windows seems to have nothing of the sort. My application needs to register some entries in the windows registry and I'm at a loss of how i could achieve this using jpackage.

I've been using Override Resources as my reference. I have tried using the Post-image script but it seems like I misunderstood what it does and it doesn't actually run during the installation. I am now looking at the .wix files to see if that would allow me to achieve what I need but I have never worked with the Wix Toolset.

Is anyone aware of a way to achieve this?


Solution

  • I seem to have found a way to solve the problem: Jpackage allows us to edit the main.wxs file. In this file, if we want to add either a command or in my case a RegistryKey, we can. Just add

    <Product>
        ...
        <Component Id='SomeComponent' Guid='SomeGUID' Directory="INSTALLDIR">
            <RegistryKey Root="HKCR/example/location" Key="foo" >
               <RegistryValue Name="bar" Value='YourValue' Type="string" />
            </RegistryKey>
        </Component>
    </Product>
    

    And inside feature:

    <Feature Id="DefaultFeature" Title="!(loc.MainFeatureTitle)" Level="1">
        ...
        <ComponentRef Id="RegistryComponent"/>
    </Feature>
    

    This should add your custom registry key in HKCR/example/location/foo and a string key "bar" with value "YourValue".