Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've tried launching several programs through a batch file and encountered problems but that is in the past.

I'm relatively new to scripts and command lines and this would be my question: What's the difference between the following cmd scripts?

This one is accepted

Start Chrome

(i'm guessing here that some installed programs are recognized by title, even though the dir is not where the chrome.exe is the program still launches, registry keys play a part in this?)

this one works also

cd "FOO_DIR"
start FOO.exe

however these don't

start "FOO_DIR\FOO.exe"

(opens a new window without launching FOO.exe)

start /B "FOO_DIR\FOO.exe"

(writes the copyright text again and does nothing else)

(OS Windows 7 x64)

share|improve this question
add comment

2 Answers 2

up vote 17 down vote accepted
Start Chrome

This one works, because Chrome's executable is located in a folder which is in the PATH environment variable. start looks for programs in all folders in that variable. The environment variable PATHEXT contains a list of file extensions to look for and as .exe is contained by default, you don't need to write chrome.exe.


start "FOO_DIR\FOO.exe"

This does not work, because start will use its first argument as the window title if it is quoted. So this will open a new CMD with "FOO_DIR\FOO.exe" as its title.

To circumvent this, you can simply add an empty title argument before your command:

start "" "FOO_DIR\FOO.exe"
share|improve this answer
    
Furthermore, AFAIR, the title is mandatory when launching executables with command-line switches –  abstrask Mar 11 at 13:07
1  
It's not that start expects a title as its first argument (otherwise start chrome wouldn't work), it's that if its first argument is quoted, it expects it to be a title. –  jamesdlin Mar 12 at 0:23
    
@jamesdlin ah, the documentation on this is a bit vague, thanks. I edited the answer accordingly –  crater2150 Mar 12 at 12:45
add comment

Try adding "title" or at least "" after start like this:

start "title" "FOO_DIR\FOO.exe"

or

start "title" /B  "FOO_DIR\FOO.exe"

The root cause of the problem is that first argument in "" quotes is interpreted as a title parameter for new cmd window.

Also it helps to look at the command reference (link)

share|improve this answer
    
Thanks, that clarified the difference. And with the first one i think that "Non-executable files may be invoked through their file association just by typing the name of the file as a command." is the reason why just the name is enough... (not sure though) –  Mr. Smith Mar 11 at 8:57
    
If you are talking about your firts example with start chrome I believe that calling chrome works, because it is has an entry in registry somewhere here: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths If you look for chrome.exe you will most likely find the entry containing full path to executable. –  smc Mar 11 at 9:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.