Eric
Eric

Reputation: 489

Execute Python script in batch file with params

I tried using the accepted answer in this post, but it isn't working. Also, how would I add params? I'm using virtualenv and trying to activate that environment and then run my script.

Current Batch File - Does not execute last line

cd\
cd c:\mydir\scripts\
activate.bat
c:\mydir\scripts\python.exe c:\mydir\scripts\myscript.py %*

Desired batch file with params - Script accepts a 2D array

cd\
cd c:\mydir\scripts\
activate.bat
c:\mydir\scripts\python.exe c:\mydir\scripts\myscript.py [[p1,p2,p3,p4],[p1,p2,p3,p4]]

Upvotes: 0

Views: 761

Answers (1)

Jeff Zeitlin
Jeff Zeitlin

Reputation: 10799

Batch files are funny. If you execute a batch file from within another batch file by just specifying the batch file name, as you would from the command line, the first batch file gets terminated. To prevent this, CALL the second batch file from the first - in your example batch file (specifically, the desired one), change the line that reads

activate.bat

to read

call activate.bat

and you should be OK.

Upvotes: 2

Related Questions