在PowerShell中的所选应用程序中打开文件

Mat*_*t W 4 powershell notepad++

我想在PowerShell中使用特定应用程序的cmdln打开一个文件.

在我的情况下,我有一个文件scripts.js,我想打开Notepad++notepad.exe如果我这样做,通常会定期打开:Invoke-Item .\scripts.js

我应该怎么做才能打开该文件Notepad++

Wil*_*ebb 10

通过使用Start-Process,您可以:

$FileLocation = 'C:\temp\test\scripts.js'
Start-Process notepad++ $FileLocation
Run Code Online (Sandbox Code Playgroud)


Ans*_*ers 6

使用调用运算符并将文件作为参数传递给要使用以下命令打开它的程序:

& 'C:\path\to\notepad++.exe' '.\script.js'
Run Code Online (Sandbox Code Playgroud)