0

I have tried the following:

set SOME_PATH="C:\some_path"
start "some program" %SOME_PATH%\pathToScript\anotherBatch.bat %SOME_PATH%\pathToConfig\some.properties

My aim is to start "anotherBatch.bat" which takes the path to a config file as an argument: %SOME_PATH%\pathToConfig\some.properties

Unfortunatley, I got an error in the new command prompt that my syntax for the file name is incorrect.

What is the right syntax for the start command above?

aschipfl
  • 33,626
  • 12
  • 54
  • 99
  • 1
    I suggest to read answer on [How to call a batch file that is one level up from the current directory?](https://stackoverflow.com/a/24725044/3074564) explaining four methods to run a batch file from within a batch file. You should embed each argument string in double quotes in case of any argument string contains a space or one of the characters ``&()[]{}^=;!'+,`~<|>``. The first double quote on assigning the path to environment variable `SOME_PATH` is also positioned wrong, see [How to set environment variables with spaces?](https://stackoverflow.com/a/34402887/3074564) – Mofi Dec 15 '17 at 12:10

1 Answers1

2

You should Call a batch file instead of Start one.

Set "SOME_PATH=C:\some_path"
Call "%SOME_PATH%\pathToScript\anotherBatch.bat" "%SOME_PATH%\pathToConfig\some.properties"

Where anotherBatch.bat will use %1 or "%~1" as the quoted argument and %~1 as the unquoted argument.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • The problem is that anotherBactch.bat is blocking call that is why i used the start command to run the batch file in another cmd window. Is there away to call anotherBactch.bat asynchronously? – MvKuegelgen Dec 15 '17 at 11:10
  • You need to properly explain to me how you believe a series of text strings inside a file with a `.bat` extension is `blocking` the `call` command which precedes it.. – Compo Dec 15 '17 at 11:41