Performing registry search for a .NET windows inst

2019-08-04 23:34发布

问题:

I have a .NET winform installer application. Before installing, I'm doing a registry search to check if MS Access Runtime is installed on the machine.

Search Target Machine

Properties of Search Target Machine

Launch Conditions

Properties of Launch Condition

However i want to avoid hard coding the path like "C:\Program Files\Microsoft Office\Office15\" in the properties of launch condition. So far i have tried "[ProgramFilesFolder]\Microsoft Office\Office15\", "%ProgramFiles%\Microsoft Office\Office15\" but both the options are not working.

回答1:

Correct Registry Search: Try to search the proper 32-bit section of the registry: SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MSACCESS.EXE

Crucial is the inclusion of Wow6432Node towards the beginning of the string.


Custom Action: It is not accepted best practice, but I like to use custom actions to inspect the system (I don't like them for making system updates). Inspection custom actions are read-only, do not require any rollback, are not dangerous to the system and you can relatively safely suppress errors.

The reason I like inspection custom actions is that you have full flexibility if system inspection requirements get more complicated. I find AppSearch gets very confusing at times. Custom actions are not easy to use with Visual Studio Installer Projects.


Bitness: I don't use App Search much, but is this an actual 32-bit machine (pretty vintage that) or a 64-bit machine with 32-bit components? In case of the latter, here is a reminder about the core bitness-dependent paths in the registry and on disk:

Registry:

  • 64-Bit: HKEY_LOCAL_MACHINE\SOFTWARE
  • 32-Bit: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node

Disk:

  • 64-Bit: C:\Program Files\
  • 32-Bit: C:\Program Files (x86)\
  • 64-Bit: C:\Windows\System32\ - (yes, really)
  • 32-Bit: C:\Windows\SysWOW64\ - (yes, really)

Links:

  • App Search - registry locations


回答2:

So this is how i finally got this to work and tested successfully on both 32bit and 64bit Windows machines.

My application is dependent on two prerequisites. 1. Crystal Report Runtime. 2. Microsoft Access Runtime.

So created registry search for both the runtimes.

And Properties for each of the Search created.

Launch Condition for each of the runtimes.

If you observe between the two conditions for each of the runtime you would find the difference in the way the condition has been set.

For Microsoft Access Runtime, i have just mentioned the Property name that was set for the Registry Search. While for Crystal Report Runtime, i have specified the value which is a specific version of runtime that should be present. In my case i was specifically looking for version "13.0.4" to be present on the machine.