Question

One of the conditions for running my installer is that a value in the registry should be different from "1", otherwise it would display an error message and quit.

This can't be done through custom actions since even the OnBeforeInstall event happens after install, so the user could terminate the setup before the rollback.

If I was using WiX it would be simples as

<Condition Message="This application cannot be installed with SOMESOFTWARE v1. Setup now will exit.">
    <![CDATA[SOMESOFTWAREVERSION <> "#1"]]>
</Condition>

<Property Id="SOMESOFTWAREVERSION">
    <RegistrySearch Id="SomeSoftwareVersion"
                    Root="HKLM"
                    Key="SOFTWARE\Some Manufacturer\SomeSoftware"
                    Name="SomeSoftwareVersion"
                    Type="raw" />
</Property>

How can I do the same without WiX?

Was it helpful?

Solution

You'll need a post build JScript for your MSI file. Or you can do it manually in Orca.

var installer = WScript.CreateObject("WindowsInstaller.Installer");
var filespec = WScript.Arguments(0);
var msiOpenDatabaseModeTransact = 1;
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);

Execute("INSERT INTO `AppSearch` (`Property`, `Signature_`) VALUES ('SOMESOFTWAREVERSION', 'SomeSoftwareVersion')");
Execute("INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) VALUES ('SomeSoftwareVersion', 2, 'SOFTWARE\\Some Manufacturer\\SomeSoftware', 'SomeSoftwareVersion', 2)");
Execute("INSERT INTO `LaunchCondition` (`Condition`, `Description`) VALUES ('SOMESOFTWAREVERSION <> \"#1\"', 'This application cannot be installed with SOMESOFTWARE v1. Setup now will exit.')");

function Execute(sql) {
    view = database.OpenView(sql);
    view.Execute();
    view.Close();
}

It will check Wow6432Node on 64-bit Windows just as WiX does

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top