<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Use title in START command

Published on
11,467 Points
4,467 Views
5 Endorsements
Last Modified:
Approved
Community Pick

1. Introduction

Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage.

The discussion was about whether you should or should not use the parameter title in this command.  It all started with a command similar to this:
    start notepad.exe C:\Foo.bar

The intention was to open the file Foo.bar in notepad.  Let us have a look at this problem.
 

2. The Problem

   start notepad.exe C:\Foo.bar
The command above seems to be fine, and it works okay, but there could be problems.  What if the program or command has a space in it?  Pretend we are using this command to open a program called My Application.exe.  What would you try?

    start My Application.exe
or
    start "My Application.exe"

The answer is that none of the commands above work.  Why?  The first tries to call a command or an application called My with the parameter value of Application.exe.  The second command just opens a new cmd.exe with the title "My Application.exe".
 

3. The Solution

The solution to the problem would be to use this command instead:

    start "" "My Application.exe"

Notice the two double quotes at the beginning.   Those are the title of the command prompt calling the command or program.
 

4. Some thoughts

But why did the initial command start notepad.exe C:\Foo.bar work without the double quotes?  Would not that be the title of the command window?  No, this is because of the way the command was written.  The command was written with notepad.exe and not "notepad.exe".  If we had written it as start "notepad.exe" C:\Foo.bar we would have the same problem.
 

5. Conclusion

To be really sure that the command start does what you want, use the title parameter first, even if you are going to do something easy as opening a file in notepad.

 The bottom line is:
If your command, program or file has a space in its name, you have to use the title parameter and put your command, program or file in double quotes.

6. EXTRA - Syntax and parameters

The simple syntax of the command is:

    START "title" "command" [parameters]

The more advanced syntax is:

    START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED]
        [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]
        [/AFFINITY <hex affinity>] [/WAIT] [/B] [command/program]
        [parameters]

Open in new window

   title – Specifies the title of the command prompt window title bar.
             Important:  This is optional.  If you use it, the quote marks are required.  

    /d path – Sets the work directory.

    /i – Starts the new window in the default startup environment.

    /min /max – Starts windows in minimized or maximized.

    /separate /shared – Starts a 16-bit application in separate or shared memory. (Not supported on 64-bit systems).

    /low /normal /high /realtime /abovenormal /belownormal – Specifies which priority the application will start in.

    /wait – Starts the command or application and waits for it to terminate.

    /b – Starts the application without starting a new window.

    /command/program – Specifies the command or program you want to start.   If you start a built-in command the command prompt will stay open after execution.

    parameters – Specifies the parameters to the command or program.

See The START command for more details.

7. EXTRA II – Tips and tricks

There are some exceptions to the command though. You might use the command without specifying a program. For instance start C:\Foo.bar. This would open the file Foo.bar with the program associated to the file type .bar.  If there is no program associated to the .bar file type, it will prompt you with the ‘Open with’ dialog.  But again, if the file has a space you have to put the file name in double quotes and also include the title parameter.
5
Author:nordtorp
6 Comments
LVL 74

Expert Comment

by:Qlemo
As one of the contributors to the question causing this article, I was indeed inclined to write a similar article. It was about time, I suppose.
Voted YES.
0
LVL 50

Expert Comment

by:DanRollins
As a long-time DOS user, I'd like to add this comment, just as a point of clarification:

The tricky, and significant, issue here is the use of quote marks as a syntax element.   START is very unusual in this respect.

If the first parameter is enclosed in quotes, the START command treats it as the (otherwise rarely needed) title parameter.    If there is no second parameter, START just opens a new DOS box.

But some program and document pathnames contain an embedded space, so one must enclose the pathname in quotes.  The article describes the clever workaround of inserting "" (quote quote) as the first parameter to avoid the problem.
0
LVL 74

Expert Comment

by:Qlemo
I agree in all said by Dan. This is really unusual for a command to depend on quotes as syntax elements (versus string delimiter). But indeed it is something each executable can handle different - DOS (cmd.exe) doesn't preparse arguments besides the command delimiters (&, |, &&,  ||) and the continuation/escape char (caret, ^).
0
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

LVL 11

Author Comment

by:nordtorp
Thank you for the comments and votes. I have updated the article with some information.
0
LVL 15

Expert Comment

by:JackOfPH
What would be the difference between this command:

start notepad.exe "c:\foo.bar"

to

notepad.exe "c:\foo.bar"

Any?
0
LVL 74

Expert Comment

by:Qlemo
No, there is no difference, it was just taken as example. start is used in that context to provide the /max or other switches for window/process control, or to start the associated program when supplying only the file, e.g.
     start /max "Title" "C:\Path with spaces\file.txt"
0

Featured Post

OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month