I'm sure there must be an easier way to run a program from PowerShell, but I haven't found anything simpler than

& "C:\Program Files (x86)\Notepad++\notepad++.exe"

with the ampersand and the full path. I could add "C:\Program Files (x86)\Notepad++" to $env:PATH, but I'd still have to type notepad++.exe file. I wanted some way to make a shortcut to a program name without having to create a new file, either a .LNK or .BAT file.

Turns out you can do this with PowerShell functions:

function npp { & "C:\Program Files (x86)\Notepad++\notepad++.exe" $args }

lets me run Notepad++ from PowerShell without nearly so much typing. Stuck that in my Profile.ps1 and now I'm happy.
Hope this turns out to be useful to someone.

Leave a Reply


Warning: Undefined variable $user_ID in /home/public/blog/wp-content/themes/evanescence/comments.php on line 75