I have created a Python script which needs to launch a .bat file based on some condition.
Python script location : \Component\myScript.py
Batch file location : \Component\MS20160825\toExecute.bat
The batch file internally uses some executables which are in \Component\bin\
How do I do following :
Launch .BAT file from Python script so that .BAT executes successfully. BAT file should be able to find executables in \Component\bin\ directory to perform its task and produces desired result.
Hold Python script execution until .BAT finished its execution.
.BAT file has pause >nul statement. I need to bypass it, meaning when .BAT is executed from Python script it should not wait for user to press Enter rather it should terminate normally after executing second last statement. Because the same .BAT file needs to be executed multiple times.
NoPauseand use in the batch fileif /I not "%~1" == "NoPause" pause >nul. Run in a command prompt windowcall /?to get help on how to make use of batch file parameters.%0references argument 0 which is the batch file itself.%~dp0is for example drive and path to batch file ending with a backslash. That might be useful to reference other folders/files from within batch file with a path relative to path of batch file.\Component\myScript.pyis relative to root of current drive. A path starting with..\references the parent directory of current directory. And a path starting with.\or with a folder or file name is relative to current directory.