6

Quick Tip - Open A File In Default Program

 1 year ago
source link: https://thomasrayner.ca/quick-tip-open-a-file-in-default-program/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Quick Tip - Open A File In Default Program

When you double click a file in Explorer.exe, it automatically opens in its default program if it has one associated with its type. But did you know you can do the same thing using PowerShell?

Most people are aware of Start-Process, the PowerShell cmdlet for starting processes on the computer, but most people just use it for executing things they’d normally just look to run in cmd.exe like installers. But Start-Process has a -FilePath parameter that you can use to open a file in its default program.

Start-Process -FilePath C:\temp\opens-in-excel.csv

On my computer, this command opens the given CSV in Excel. This is handy in situations where you’re poking around in the console, exporting files, and then perhaps you wish to open that file and rather than clicking around inefficiently through Explorer.exe, you can just launch it from the PowerShell CLI.

Written on February 14, 2018

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK