要从 PowerShell 中打开 Windows 10 默认应用程序中的文件,请按照以下步骤操作:
start "" "C:\path\to\your\file.ext"
例如,要在默认 Web 浏览器中打开名为 example.html
的文件,可以输入以下命令(确保替换为实际文件路径):
start "" "C:\Users\YourUsername\Documents\example.html"
或者,如果你想使用特定的应用程序打开文件,可以使用该应用程序的名称。例如,要以 Notepad++ 打开 example.txt
文件,请输入:
start notepad++ "C:\Users\YourUsername\Documents\example.txt"
请注意,start
命令会立即在后台启动默认应用程序并打开文件。如果您想在启动应用程序后暂停 PowerShell 并等待用户完成操作,可以在命令末尾添加 -Wait
参数,例如:
start -Wait notepad++ "C:\Users\YourUsername\Documents\example.txt"
这样,PowerShell 将等待 Notepad++ 关闭后才继续执行后续命令。
领取专属 10元无门槛券
手把手带您无忧上云