tinynja98

New Member
Joined
Jun 25, 2017
Messages
2
Hello, I am trying to open a file [FILE] with a program [PROGRAM]. I have a shortcut of those two on my desktop. When i drag and drop [FILE] on top of [PROGRAM], it works as expected, meaning that [FILE] gets openend correctly by using [PROGRAM] to open it (Similarly to how you would drop a ".txt" file on top of Notepad to edit it.) Now, when I tried in the terminal to write this start "[PROGRAM]" "[FILE]", the program gets opened as if I simply double clicked on it, meaning that [FILE] does not get opened with [PROGRAM].

What does dragging and dropping [FILE] on top of [PROGRAM] do more than the command I ran which makes it work? And how can I achieve the same result via command line?

EDIT: Creating a shortcut (.lnk file) on desktop to ""[PROGRAM]" "[FILE]"" works as I want it to.
EDIT2: I found a solution to my initial problem by doing something similar to my first edit, but if you know why the start "[PROGRAM]" "[FILE]" command didn't work, I would be very interested to know.
 

Last edited:
Solution
Well thanks for your reply it made me look a little deeper into this. After some research, I found that I should have used start "" "[PROGRAM]" "[FILE]" as the first quote is used as the title of the new cmd window that will get opened. Also, I realized that I was using PowerShell (never used it before, so I supposed it was the same thing as cmd :culpability:) when I did my tests before I posted this thread, and I tried with cmd.exe and it worked flawlessly with the command start "" "[PROGRAM]" "[FILE]". Powershell gives me an error when I try the last command.
Isn't it that start opens a new CMD-window and that "[PROGRAM]" is not one of the options recognized by it?
Start a CMD-windows and type help and type later start /?
 

Well thanks for your reply it made me look a little deeper into this. After some research, I found that I should have used start "" "[PROGRAM]" "[FILE]" as the first quote is used as the title of the new cmd window that will get opened. Also, I realized that I was using PowerShell (never used it before, so I supposed it was the same thing as cmd :culpability:) when I did my tests before I posted this thread, and I tried with cmd.exe and it worked flawlessly with the command start "" "[PROGRAM]" "[FILE]". Powershell gives me an error when I try the last command.
 

Solution
Thanks for your reply, that explains it all.

And most of all
Welcome to this forum, keep joining us, keep enjoying yourself!
 

Start is a CLI command in command prompt and Start is an alias for Start-Process in powershell. They don't quite accept the same arguments
 

I do something like:
notepad file.txt

Replace notepad with the program you want to open your file with and replace file.txt with the name of the file (and its extension) that you want to open.

In action:
 

Hi melbel — welcome back. Your shortcut/drag‑and‑drop behavior is normal; here’s why your commands behaved differently and how to do the same from both cmd.exe and PowerShell.
Why your first command failed
  • In cmd.exe the built‑in start command treats the first quoted argument as the new console window’s title. So
    start "Program" "C:\path\file.ext"
    makes "Program" the window title and then starts "C:\path\file.ext" (which is treated differently).
  • The fix in cmd is to give an explicit (possibly empty) title, e.g. start "" "C:\path\program.exe" "C:\path\file.ext".
  • In PowerShell start is an alias for Start-Process (not the cmd start), and it parses arguments differently — the same string form will not work there.
How drag & drop works
  • Dropping a file onto a program or its shortcut launches that program with the file path passed as a command‑line argument (or invokes the program’s shell verb). So to replicate drag & drop you simply run the program with the file path as an argument.
Examples
1) From cmd.exe
  • If program is on PATH:
    notepad "C:\path\file.txt"
  • If program path contains spaces or you want to use start:
    start "" "C:\Program Files\MyApp\app.exe" "C:\path\file.ext"
2) From PowerShell
  • Use Start-Process:
    Start-Process -FilePath "C:\Program Files\MyApp\app.exe" -ArgumentList "C:\path\file.ext"
  • Or use the call operator (&) which behaves like running the exe directly:
    & "C:\Program Files\MyApp\app.exe" "C:\path\file.ext"
  • To call the cmd start from PowerShell:
    cmd.exe /c start "" "C:\Program Files\MyApp\app.exe" "C:\path\file.ext"
Notes / tips
  • Always quote paths that contain spaces.
  • If you want the same behavior as dropping onto a shortcut that already has arguments in its Target, create a shortcut whose Target includes "%1" (or the file path) or run the program with the filename as an argument.
  • Some programs use DDE or custom shell verbs; in those rare cases the shell may use a different mechanism than a simple command‑line argument, but for most programs the examples above reproduce drag‑and‑drop.
If you tell me the exact program and file paths you’re using I’ll give the exact command line to run (for cmd and for PowerShell).
 

Back
Top