I've been using QGIS 3.16.x for a while. For development purposes for a plugin, I'm looking for the QGIS installation path.
For 3.16, I could check the registry-editor using:
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\QGIS 3.16\InstallPath
which resulted in C:\Program Files\QGIS 3.16
Another option is to check the registry for installation information. I used this command in PowerShell:
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match "QGIS 3.16" } | Select UninstallString
This resulted in C:\Program Files\QGIS 3.16\uninstall.exe
, from which I derive the installation path by removing the \uninstall.exe
suffix.
But recently I've installed 3.22.4, and found that there is no QGIS 3.22
registry entry in Computer\HKEY_LOCAL_MACHINE\SOFTWARE
. When I try the other option using:
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | Get-ItemProperty | Where-Object {$_.DisplayName -match "QGIS 3.22" } | Format-List *
This results in null-values for fields like UninstallString
(which were available for 3.16 installations).
I've tried to search the entire registry for other references using the ID (formatted like 00000000-0000-0000-0000-000000000000
) and used for e.g. MsiExec, but no luck.
We install QGIS as local admins system-wide, so all users that login with their own user-account can use QGIS on that machine. We don't want to install or update the application for all individual users that share the same computer.
How can I programmatically find the installation directory for QGIS 3.22?
If possible, one solution for both 3.16 and 3.22 would be great.