Open Notepad++ from PowerShell

How can I open up a file in Notepad++ from the Powershell command line?


Inside powershell I can simply use the start and get general results

to open a python file with notepad++ here is what I did.

Start notepad++ ex1.py

this will start notepad++ and load the file ex1.py assuming you are in the same directory as the .py file. You can change that by adding the full path name

start notepad++ c:\users\you\desktop\files\ex1.py

Hope this helps!


Because the default path contains spaces, you have to quote the path to the exe. However because PowerShell is also a scripting language. A string by itself is simply evaluated as a string e.g.:

C:\ PS> 'Hello world'
Hello world

So you have to tell PowerShell you want to invoke the command that is named by the string. For that you use the call operator & e.g.:

C:\ PS> & 'C:\Program Files (x86)\Notepad++\notepad++.exe'

or if notepad++ is in your path:

  C:\ PS> notepad++

or if you're in the same dir as the exe:

  C:\ PS> .\notepad++

To open Notepad++ with and create a new empty file in the current path

start notepad++ newFile.txt

To open Notepad++ with an existing file

start notepad++ apples.txt

To specify the path and open multiple files

start notepad++ fruits/apples.txt, fruits/oranges.txt, package.json

To extrapolate on the previous answers and tie them up in a tidy bow: If you want to open a file with spaces in the path or name:

. 'C:\Program Files (x86)\Notepad++\notepad++.exe' 'C:\Temp\File With Spaces.txt' 

or

& 'C:\Program Files (x86)\Notepad++\notepad++.exe' 'C:\Temp\File With Spaces.txt'

It can also be set it as an alias:

Set-Alias -Value 'C:\Program Files (x86)\Notepad++\notepad++.exe' -Name 'NotePad'
$FileWithSpaces = 'C:\T e m p\File With Spaces.txt'
NotePad $FileWithSpaces

The top line here can be copied into (one of) your $Profile .ps1 file(s) so you don't need to keep using Set-Alias in every new PS instance.