MvKuegelgen
MvKuegelgen

Reputation: 11

How to start a windows batch file with variables from another batch file

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?

Upvotes: 0

Views: 2464

Answers (1)

Compo
Compo

Reputation: 38654

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.

Upvotes: 2

Related Questions