简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM