Im using the Shortcut Target function to open a stripped down version of QGIS, and for those who know QGIS, there's multiple versions being used by multiple users at any given time. Im looking to have one 'tool' that opens any available QGIS instal, not just the one version the target has been assigned.

The 'tool' currently opens a stripped back version of QGIS, removes a lot of the tools etc. Used for just viewing data, turning layers on and off. Now I currently have multiple shortcuts set up with each of the targets as "C:\Program Files\QGIS 3.10\bin\qgis-ltr-bin-g7.exe" or "C:\Program Files\QGIS 3.4\bin\qgis-ltr-bin-g7.exe" etc etc depending on the version.

Now my question, is there a way to have just one 'tool' that looks for the installed version of QGIS rather than separate icon for each version. Some kind of wildcard function or IF/THEN function.

Im not sure if ive explained this too well, but hopefully someone out there can help.

Screenshot of the file target path

^^^ Added a screenshot of the target path, id ideally like to do it that way rather than run a script? If there was a wildcard or multiple folder expression?

  • You could easily write a script that checks for each of a list of executables in turn and executes the first one it finds. Mar 31, 2021 at 22:13

1 Answer 1


In PowerShell you'll write a script that checks for each of a list of executables in turn and executes the first one it finds.

# Folder paths only
$path1 = "C:\Program Files\ApplicationV1\"
$path2 = "C:\Program Files\ApplicationV2\"
$path3 = "C:\Program Files\ApplicationV3\"

# Name of executable
$executable = "app.exe"

# Running it
if("$path1\$executable") {
    Set-Location $path1
if("$path2\$executable") {
    Set-Location $path2
if("$path3\$executable") {
    Set-Location $path3
Else {
    Write-Host "No executables found."

I haven't tested this, and I know I could simplify it with an array and a loop, but this is what 3 minutes of effort gets me. This script assumes the executable would be named the same, but could easily be re-written, with hashes, to allow flexibility in the name of the executable as well.

The key concepts are that PowerShell doesn't let you just run an executable unless you take a few things into consideration, for instance you need to be in the directory of the executable before you can run it, and then you want to exit the script once you've found an executable to run in order to avoid finding and running subsequent lists.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .