In Windows we access the Run box with Windows Key + R
. Then we can run a program by name (e.g. firefox, snippingtool). Is there a way to run a
As @briantist mentioned in his answer (+1): the "Run" dialog (which probably calls the ShellExecuteEx function) checks the subkeys of the App Paths
registry key in addition to the paths in the $env:PATH
environment variable.
For emulating the behavior of the "Run" dialog I would, however, add the folders to $env:PATH
instead of creating aliases for each executable:
$regkey = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths'
$appPaths = Get-ChildItem $regkey |
Get-ItemProperty |
? { $_.'(default)' } |
select -Expand '(default)' |
Split-Path -Parent |
% { [Environment]::ExpandEnvironmentVariables($_.TrimStart('"')) } |
select -Unique
$env:PATH += ';' + ($appPaths -join ';')
By adding this to a PowerShell profile (e.g. your personal profile %UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
), the variable $env:PATH
of each PowerShell instance you start is updated with the additional paths from the registry. Note, however, that by adding too many folders you might be hitting length restrictions.