Pass parameters to executables from the PS command line.

Working from within the PowerShell ise sometimes you still need to run an external editor to edit a text file. I use Notepad++ for this purpose and it is a pain to invoke it from within the command line and to pass the name of the file that I want to edit at the same time.  Here is how you can start NotePad++ by itself.

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

Note that the full command string is within double quotes, to accommodate the spaces in the folder names. Because the strings are quoted, we also need to to preface the string with the at “&” sign, which means “execute this….”

Now, typically I’ll have an existing text or html file that I already want to edit.  This can be appended to the command.

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

Notepad++ will open multiple files in separate tabs that are passed to it when opening.

& "C:Program Files (x86)Notepad++notepad++.exe" winners.txt,loosers.txt

More details are in this article at Windows IT Pro.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s