Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open file in chosen application in PowerShell

I would like to open a file using the cmdln in PowerShell with a particular application.

In my case, I have a file scripts.js which I'd like to open in Notepad++ but which would normally open in regular notepad.exe if I did this: Invoke-Item .\scripts.js

What should I do to open that file in Notepad++?

like image 829
Matt W Avatar asked Mar 08 '17 11:03

Matt W


2 Answers

By using Start-Process you can do:

$FileLocation = 'C:\temp\test\scripts.js'
Start-Process notepad++ $FileLocation
like image 102
Will Webb Avatar answered Oct 23 '22 03:10

Will Webb


Use the call operator and pass the file as an argument to the program you want to open it with:

& 'C:\path\to\notepad++.exe' '.\script.js'
like image 29
Ansgar Wiechers Avatar answered Oct 23 '22 01:10

Ansgar Wiechers