user3166813
user3166813

Reputation: 99

Cannot run python server using batch file

Here are the commands in batch:

D:
cd D:\Startup\venv\Scripts
activate
cd D:\Startup\
python manage.py runserver

Commands after "activate" are not executed for some reasons. I tried to put "cmd /k activate" instead "activate" but result is still the same except the command line is still open. What is wrong here

Upvotes: 1

Views: 1512

Answers (1)

Mofi
Mofi

Reputation: 49096

I suppose activate is a batch file and therefore needed is:

cd /D D:\Startup\venv\Scripts
call activate.bat
cd D:\Startup
python.exe manage.py runserver

Without command call the processing of a batch file continues on other batch file without returning which is the reason why the last two lines where never executed. Run in a command prompt window call /? and read output help and for more details see for example also answer on How to call a batch file in the parent folder of current batch file?

Command CD with parameter /D makes it possible to change directory and drive at the same time as cd /? executed in a command prompt window explains.

In batch files it is advisable to specify batch files and executables with file extension.

Upvotes: 3

Related Questions