DOS Batch Start Command used with quotes and parameters fix

In my line of work I like to automate everything possible to make life for myself and others easier. One command used extensively is Start /wait or just plain old Start to have a batch file proceed in order one step at a time. However when doing something such as:

start /wait "c:\My Files\Setup.exe" /silent /norestart

will result in a friendly Invalid Switch – "/silent". Yet taking the space out of the "My Files" folder and adjusting the command to match that, will suddenly have this work. I get annoyed and just have to find the solution no matter the cost when I can't figure out why things just don't work >:( The problem here is that the quotes throw off the input the start command is expecting. Take a look:

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

The quoted path to the Setup.exe becomes the title, hence why another command window pops up with that name. Solution? Quite simple now that you know that:

start /wait "ANYTHING!" "c:\My Files\Setup.exe" /silent /norestart

Nothing great here, just a problem I keep on stumbling on, forgetting the fix, and rummaging through everything I can find to figure out what it was. Hopefully I'll remember this post next time…

17 Responses to “DOS Batch Start Command used with quotes and parameters fix”

  1. Braden says:

    finally! I've been looking everywhere for this! thanks!

  2. Zen0n says:

    It looks that we have similar approach to automation at work and are facing similar problems with it. Thank you for this enlightening article! This proves that sometimes it is a good idea to take another look at a particular command syntax. Thanks again.

  3. Someone says:

    Thank you!

  4. Sandra says:

    Brilliant deduction! Thanks for this.

  5. George says:

    I’d been banging my head on this for hours, what a joy to locate your answer. I’d probably never have noticed the title bar.

  6. Denise says:

    I have an issue where I want to use ‘start’ to run my exe because I want to use the /wait parameter so that I know when my exe has completed. The issue I have is that I want to pass in a param file but the ‘start’ call does not allow me to use a file name as my parameters to the exe.

    Anyone got any ideas?

  7. Administrator says:

    Hi Denise,

    Can you give an example? It sounds like the article I posted is solving the exact issue you are speaking of. If you can post the syntax I can take a stab at it.

  8. Denise says:

    Hi Mike,

    I am currently using this code to run an exporter and passing a paramfile through to it as the instructions are quite long.

    “C:/Testing/Export.exe” /Execute export /paramfile “C:/Testing/param.tmp”

    I was trying to use the start command as I need to know when the process is finished before continuing with other tasks. This is the code that I have used:

    start “Mines_Department_Export” “C:/Testing/” /wait /b “RunExporter.bat”

    I am currently using TASKLIST > “C:/Testing/TaskList.txt”

    Then I am using a Perl script to check that the file contains Export.exe to see whether it is running. It is such a long winded way to go about it and would be so much easier to have the dos start command wait and let me know when the process is finished.

    Denise

  9. Administrator says:

    Can you show the line you used before that was failing with /start wait?

    Also, one alternative is to download a utility called AutoIt, it generates exe’s and having it run and wait for something to finish is quite easy. You could do it all in one line, then compile it.

    You would basically use this command:
    http://www.autoitscript.com/autoit3/docs/functions/RunWait.htm

    It would look like this.
    RunWait(‘”C:/Testing/Export.exe” /Execute export /paramfile “C:/Testing/param.tmp”‘)

    It might be easier than trying to figure out the dos command.

  10. Denise says:

    Hi Mike,

    Below is the other line of code that failed when I ran it:

    echo “C:/Testing/Export.exe” /Execute export /paramfile “C:/Testing/param.tmp” > “C:/Testing/RunExporter.bat”
    start “MD_Export” “C:/Testing/” /wait /b “RunExporter.bat”

    I was passing the run line to execute out to a batch file as I couldn’t figure out the syntax to make start work when I had a param file to pass to it as /paramfile is not one of the parameters allowed with the start instruction.

    I have the Perl Script running that lets me know when the process is finished running and am still testing.

  11. Administrator says:

    Sorry, lets got back a step. I’m getting confused. This is essentially the piece of script you need to run, and wait for a command to follow:

    “C:/Testing/Export.exe” /Execute export /paramfile “C:/Testing/param.tmp”

    What does this do? Can you post any errors or troubles this gives?

    start /wait “Export Process” “C:/Testing/Export.exe” /Execute export /paramfile “C:/Testing/param.tmp”

  12. Denise says:

    Hi Mike,

    Thanks very much for your help. The code you suggested above works really well: start /wait “Export Process” “C:/Testing/Export.exe” /Execute export /paramfile “C:/Testing/param.tmp”

    :-)

  13. zickbert says:

    Great explanation. Thanks a lot!

  14. James says:

    Thanks, very helpful … which all the weird problems had such an easy fix!

  15. Jack says:

    N00b on batch commands. Any advise on how to make sure multiple folders load up according to your preference?

    start /wait /min C:\Folder1
    start /wait /min C:\Folder2
    start /wait /min C:\Folder3
    start /wait /min C:\Folder4
    and so on…

    However most of time the folders don’t load as folder1 folder2 and so instead its random. Might be folder1 folder3 folder4…

  16. Jack says:

    I found the answer instead of

    start /wait /min C:\Folder1

    I should use

    start /wait /min explorer C:\Folder1

  17. Tom says:

    this is what I use to check for running tasks that popup annoying msg boxes that stop my work.
    change the obvious values to what you need.

    use the command below to kick off a bat file named kill task
    start “Testing for PGP Desktop” killtask.bat

    ========================================
    Echo Off
    REM * Bat file to kill task that checks for cmd.com.
    REM * Testing for task with window title “My Window”.
    @ECHO OFF
    cls
    @ECHO Testing for task with window title “My Window” …
    :start
    ping -n 5 127.0.0.1>nul
    @ECHO Testing for task with window title “My Window” …
    tasklist /FI “WINDOWTITLE eq My Window” 2>NUL | find /I /N “msiexec.exe”>NUL
    if errorlevel 1 goto start
    if errorlevel 0 goto kill
    :kill
    @echo Window found, killing window
    taskkill /fi “windowtitle eq My Window” /f
    goto end
    :end
    pause
    exit
    ========================================

Leave a Reply

Copyright © 2002-2014
Tech Bloggings