• A twist on 'start /wait

    Home » Forums » AskWoody support » Windows » Windows 10 » Questions: Win10 » A twist on 'start /wait

    Author
    Topic
    #347301

    I am trying to get a batch (.cmd) file to run an executable and wait until it has finished before executing the next batch command. I believe ‘start /wait’ is supposed to do this – but it is not happening for me.

    If I run:

    CD “C:\Program Files\Allway Sync\Bin\

    “C:\Program Files\Allway Sync\Bin\”syncappw.exe -s “Sun” -e””

    all is ok in that syncappw runs, and if I put a timeout command after the syncappw command then everything works – provided the timeout is long enough.

    But if I use

    CD “C:\Program Files\Allway Sync\Bin\

    start /wait “C:\Program Files\Allway Sync\Bin\”syncappw.exe -s “Sun” -e””

    it always parses incorrectly wherever I put the quotes, and never runs syncappw. For example, running exactly as shown here I get “Windows cannot find ‘-s’.” Have I just not found the right places to put the quotes or is something else happening here”

    Viewing 9 reply threads
    Author
    Replies
    • #347304

      I assume, since the topic was placed in the Win10 Forum, you are running Win10. What version of Win10 are you running?

      1 user thanked author for this post.
    • #347307

      Try
      cd “C:\Program Files\Allway Sync\Bin\”
      call “C:\Program Files\Allway Sync\Bin\syncappw.exe” -s Sun -e

      Note especially the location of the double-quotes.
      You may not need the initial cd line.

      BATcher

      Plethora means a lot to me.

    • #347313

      As you have made a guess in your post, It is a syntax problem.

      Try this line:

      start /wait “C:\Program Files\Allway Sync\Bin\syncappw.exe -s Sun -e”

      Or try this

      start /wait “C:\Program Files\Allway Sync\Bin\syncappw.exe” -s “Sun” -e””

      You may have to tweak those even more to get the right result.

      • #347353

        So this format does not work?:

        Start /WAIT “C:\Program Files\Allway Sync\Bin\syncappw.exe” -s “Sun” -e

    • #347329

      Thanks all

      Win 1803

      syncappw requires the Sun parameter to be in quotes, so for the next trials I have mostly kept to that.

      Call “C:\Program Files\Allway Sync\Bin\syncappw.exe” -s “Sun” -e

      This ran syncappw but did not wait for it to finish before executing the following batch file commands – which is definitely not what is wanted.

      start /wait “C:\Program Files\Allway Sync\Bin\syncappw.exe -s “Sun” -e”

      This runs this command, and opens another cmd window at >C:\Program Files\Allway Sync\Bin\, but with no command so it just stalls. Same result if the quotes left off Sun.

      start /wait “C:\Program Files\Allway Sync\Bin\syncappw.exe” -s “Sun” -e””

      Also produced the same result.

       

    • #347337

      I tested my BATch file using:
      call notepad.exe
      echo Hello! Notepad has just finished!
      pause

      and notepad just sat there until it was closed, whereupon the echo command was executed.
      Prosumably AllWay Sync is doing something unusual.

      I get the same results with:
      start /wait notepad.exe
      echo Hello! Notepad has just finished!
      pause

      The -e”” parameter should not have double quotes at all.

      Try successively
      “-s Sun -e”
      “-s Sun” -e

      to see if Allway Synce accepts either form.

      (Is there no Allway Sync documentation which shows you how they want its command-line parameters specified?)

      BATcher

      Plethora means a lot to me.

    • #347355

      The /wait switch is deprecated in Windows 10 1809, and may very well be the same in 1803.  To find out, in a Command window type (without the quotes) “/wait /?” and hit Enter.

      Aternatively, you can type “help” at the prompt, and scroll down the list to see if WAIT is there.

      You may have to use Powershell to get what you want done.  Retired Geek is the GoTo guy for Powershell scripts.

      Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
      We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
      We were all once "Average Users".

      • #347359

        It’s not. Try “start /?”.

      • #347429

        No mention of “/wait” being deprecated in 1809 either.

        Though the CMD syntax handling of multiple quotes and quoted quotes has always been sort of weird. PowerShell is better with that – as are most variants of sh (including bash) if you’d happen to go with that way.

    • #347360

      Check the syntax of the Start command (type “start /?” in a command window). Start interprets the first quoted sting in the argument list as a title, which is why the application appears to be ignored. The title is mandatory if there are any quoted strings in the command line, but it can be empty. You’ll need something like:

      start “” /wait “C:\Program Files\Allway Sync\Bin\syncappw.exe” -s “Sun” -e

      1 user thanked author for this post.
    • #347375

      Thanks again to everyone.

      /Wait is listed in 1803 under start /?

      start “” /wait “C:\Program Files\Allway Sync\Bin\syncappw.exe” -s “Sun” -e

      – worked Hooray (after a hitch), so I have not retried “call”

      The hitch? If I cut and pasted the line from this forum it did not work. Checking the script run time showed that the double quotes had been interpreted by cmd as Greek characters! In Notepad they showed up as double quotes, but the ‘before different from after’ kind. Replacing them with  Notepads standard quotes fixed that problem.

      My searching did not find any original info on deprecation of the /wait switch in Windows 10 1809. Can you please point to a source? Was an alternative suggested? Or is this just part of the move to Powershell?

       

      • #347691

        The command prompt does not support Unicode which is why the Greek characters suddenly appeared in your script. 🙂

    • #347408

      I should have also added to my response to BATcher. The response you got with “call” and notepad is interesting, and maybe what is wanted sometimes, but is not what I need now. I need syncappw to run to completion and then the next command in the batch file to run, without human intervention.

      AllwaySync’s documentation on calling it from a command line is perfectly clear. I this case its

      syncappw.exe -s “Sun” -e

      It was how other parentheses should be added to deal with the spaces that was unclear to me.

    • #347421

      AllwaySync’s documentation on calling it from a command line is perfectly clear. I this case its

      syncappw.exe -s “Sun” -e

      It was how other parentheses should be added to deal with the spaces that was unclear to me.

      When in a BATch file a program terminates, either successfully or unsuccessfully, control passes to the statement which follows it. Thus the operation ia working correctly, and it is just a matter of getting Allway Sync to run successfully by the correct specification of its parameters. I assume from your previous post that you’ve got it to work?

      The rule for using double-quotes in program paths containing spaces is to put one at the start and one at the end of the path. Thus
      “X:\folder name\lower folder name\programname.exe”

      BATcher

      Plethora means a lot to me.

    Viewing 9 reply threads
    Reply To: A twist on 'start /wait

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: