开发者

How to determine the folder that a previous WIX Install installed a program in

开发者 https://www.devze.com 2023-04-04 12:22 出处:网络
The existing installer for our product does not write any information to the registry, nor does it write any custom environment variables.The user is allowed to change the install directory in the ins

The existing installer for our product does not write any information to the registry, nor does it write any custom environment variables. The user is allowed to change the install directory in the installer's UI. When I'm doing an upgrade, how do I find out what folder the previous version was installed into?

I need to know the folder so I can find the previous configuration file & copy values from it. The new version's configuration file开发者_运维知识库 has new tags and a new structure, so I can't just keep the previous file & reuse it.

Tony


MSI doesn't have that information directly. (MSI packages can have multiple "root" directories, so there's no telling which one a developer might want.) If you have the directory in the registry, use RegistrySearch. Otherwise, you can use MsiGetComponentPath in a custom action.


I've done some research into this and here's the solution that I came up with:

When the installer finishes installing, it creates a node in the registry under the path

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<Product ID>

for 32 bit installs on 32 bit OS or 64 bit installs on 64 bit OS, or

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\<Product ID>

for 32 bit installs on 64 bit OS.

This node contains a value called InstallLocation which gives you the path to where the executables are installed.

Unfortunately, the previous version of our installer did not set this property, so I can't use it. BUT our installer creates a Service. I have found the path to the node in the registry for that service. From there, I can retrieve the value of the ImagePath value and extract the path from the service's .EXE file name.

So my solution is to:

  1. Fix the new installer so it does set the InstallLocation value.
  2. When upgrading from the previous version only, it will retrieve the registry node for the service & use the service's ImagePath key.
  3. If upgrading from any later version, we'll retrieve the Uninstall node and use the InstallLocation key.

Tony


msiexec keeps a copy of the msi from the last install so it will handle uninstalling the previous version you will need to just include the InstallExecuteSequence section

<InstallExecuteSequence>
  <RemoveExistingProducts After="InstallValidate" />
</InstallExecuteSequence>

This will only work if you are using the same UpgradeCode attribute in your Product Element.

Good Luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消