Search code examples
windowswinformswindows-installer

Performing registry search for a .NET windows installer application


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.


Solution

  • 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: