Jump to content

A Little Tip For Using The START Command


pinout

Recommended Posts

I thought I would share something I finally discovered that I was doing wrong when using the START command.

From what I've seen, most people use the START command in this manner:

START /WAIT C:\path\to\exe\some.exe

This works fine, but not if the path contains spaces.

So one would think that to use the START command with a path that contains spaces, you would simply use:

START /WAIT "C:\path with spaces\some.exe"

But it doesn't work that way.

Lets look at "START /?" in Command Prompt:

START ["title"] [/Dpath] [/MIN] [/MAX] [/sEPARATE | /SHARED]

[/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL]

[/WAIT] [command/program]

[parameters]

The FIRST quoted parameter is actually the title of the window, so using the command:

START /WAIT "C:\path with spaces\some.exe"

will actually open a new command prompt window with a title of "C:\path with spaces\some.exe" and not actually execute some.exe

The trick is to provide a title parameter, which can be anything you want:

START "" /WAIT "C:\path with spaces\some.exe"

I just use double quotes with nothing in between (null)

I always just assumed this was a limitation of the START command or that I didn't know how to use it properly, until I came across a post on alt.msdos.batch.nt (Windows NT tricks, traps and undocumented features)

Your current START commands probably work just fine, but I find this usefull when the name of an installer EXE contains spaces, then I dont have to rename it (I like to preserve original filenames).

Link to comment
Share on other sites


an what, if i use a command with no spaces in path but

variables? like:

start /wait msiexec /x{B060295C-E378-484C-91BE-DB5C41383FE9} /qb

I dont really know what you are asking?

I just use START "" /WAIT no matter what because if you pass any parameter thats quoted without first providing a title parameter, you'll run into problems.

You could do: start "" /wait msiexec /x{B060295C-E378-484C-91BE-DB5C41383FE9} /qb

even though its not really necessary in your case

Link to comment
Share on other sites

Despite a good note from you, no path next to "start /wait" had spaces in all posts I've seen on this forum!

People type this:

start /wait "%systemdrive%\Install\appname\app.exe" /switch

With or without quotes, no difference.

Thank you for your contribution.

Link to comment
Share on other sites

Despite a good note from you, no path next to "start /wait" had spaces in all posts I've seen on this forum!

People type this:

start /wait "%systemdrive%\Install\appname\app.exe" /switch

With or without quotes, no difference.

Thank you for your contribution.

Nope, if you use quotes it will not work, try it!

1. Open a Command Prompt

2. Type: START /WAIT "%SYSTEMROOT%\system32\calc.exe"

3. It doesn't open up calc.exe

4. Remove the quotes and it does

Link to comment
Share on other sites

quotes are used for spaces

start /wait "%systemdrive%\Install app name\appname.exe" /switch

Yes, quotes are necessary for spaces, but if you dont provide a TITLE parameter using quotes, it will not work!

I dont think you guys are actually TRYING these commands before replying.

Will work:

START /WAIT C:\PATH\APP.EXE

START "title" /WAIT "C:\PATH\APP.EXE"

START "title" /WAIT "C:\LONG PATH\APP.EXE"

Will NOT work:

START /WAIT "C:\PATH\APP.EXE"

START /WAIT "C:\PATH WITH SPACES\APP.EXE"

Link to comment
Share on other sites

  • 3 months later...

While we're discussing the start command, I'll mention another quirk I have noticed. If you use the /wait parameter, followed by the /b parameter, then the /wait parameter will not be honored. For those who don't recall, /b will completely hide the command window. However, usage of /b also seems to interfere with the /wait parameter, causing the script to immediately pass control to the next line even if the command invoked with /wait /b has not yet completed. Just FYI...

- Ravashaak

Link to comment
Share on other sites

Thanks! This is good info. Even though most people seem to avoid spaces, this info should be made more promenant because it is behavior by the start command that goes against what feels like common sense. So if people have this problem it would be very confusing to debug.

Good to know.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...