How do I launch a program from command line without opening a new cmd window?

Viewed 223511

I'm trying to programmatically execute an external file from cmd using this command:

START "filepath"

Where "filepath" is the path of my file. It opens fine but it also open a new command prompt window.

So, which is the right command for opening an external program without opening a new window?

10 Answers

20190907

OS: Win 10

I'm making an exe in c++, for some reason usting START make my program fail.

So, just use quotes:

"c:\folder\program.exe"

It's easier and safer to use the explorer.exe to start files/executeables, it is also opening files with the associated program and runs executables directly, if you execute:

start "" "%windir%\explorer.exe" "C:\Path\To\some.pdf"

If *.PDF files are not associated with any program. This works similar to a double-click and triggers the "open with program" dialog.

start "" "%windir%\explorer.exe" "%windir%\system32\calc.exe"

Will bring up the calculator.

start "" "%windir%\explorer.exe" "C:\pagefile.sys"

Will bring up a warning like: You are trying to open a system file (*.sys)... choose a programm...

Important

explorer.exe always requires the full path to the executable/file, not the relative path. If you want to use relative paths, use

start "" "%windir%\explorer.exe" "relative\file.pdf","C:\dir\"

Security related

Using start "" "some\file.dat" will try to execute the file as binary file and start it, if possible. This can end in security related issues. You can test it by creating a copy of cmd.exe calling it dummy.dat and start it using start dummy.dat

1-Open you folder that contains your application in the File Explorer. 2-Press SHIFT and Right Click in White Space. 3-Click on "Open command window here". 4-Run your application. (you can type some of the first characters of application name and press Up Arrow Key OR Down Arrow Key)

Related