How to open a file from the command line with a specified program? How to open a file from the command line with a specified program? windows windows

How to open a file from the command line with a specified program?


All you need to is provide the filename as a command line argument:

photoshop <path to file>

(<path to file> needs to be quoted if it contains spaces)

For example:

photoshop "C:\Users\csterling\Documents\some document.pdf"

If the directory containing photoshop.exe isn't in your Path environment variable, you'll need to provide the full path:

"C:\Program Files\Adobe\Photoshop\photoshop" "C:\Users\csterling\Documents\some document.pdf"

This isn't a feature of the command prompt, it's a feature of the executable, i.e. photoshop.exe has to be programmed to accept a file to open as a command line argument. Fortunately, it is, as are the majority of Windows applications that operate on files.


In case you want this to work with relative path in PowerShell, here is the script:

function photo{   $the_filename=resolve-path $args[0]   photoshop $the_filename}

Then you can just type:

cd C:\Users\csterling\Documentsphoto mypic.jpg


You can do it by using the start command:

start <program-name> <file-path>

In your case, you would have to do something like this:

start photoshop D:\open.pdf