My program is supposed to be installed to a path that recorded in registry. If the registry key is not found, then install to another(default) path.
For example, I’d like to have something like:
<Property Id="MYINSTALLDIR">
<RegistrySearch Id='MyRegistry' Type='raw' Root='HKCU' Key='Software\MyApp\Foo' Name='InstallDir' />
if not found, then set "MYINSTALLDIR" to "D:\working\defaultApps"
</Property>
How should I write my wxs file to make this happen?
EDIT:
The problem now is:
if not found in registry, then set "MYINSTALLDIR" to LocalAppDataFolder
I tried
<Property Id="MYINSTALLDIR" Value="LocalAppDataFolder">
<RegistrySearch Id='MyRegistry' Type='raw' Root='HKCU' Key='Software\MyApp\Foo' Name='InstallDir' />
</Property>
But error returned:
Error 1606. Could not access network location LocalAppDataFolder.
From memory the example below should work. If no value is found for the search, the property gets the default value. It’s only overwritten if the search succeeds.