fdzworkzone
fdzworkzone

Reputation: 121

Windows Batch start python script with pipe

I'm trying to create a batch script or scheduled task that can run this:

pythonw manage.py runserver >nul

This will run if I wrote it from a command prompt, and return me the prompt, but if I try to run it using a batch file or an scheduled task it will open a window and lock itself in that command. The window I will close adding a final "exit" but it will be locked in the first command unless I kill the process in the task manager.

How can I do this? if it works in the normal cmd why don't work the same way when in a .bat or .cmd file?

Upvotes: 3

Views: 1087

Answers (1)

fdzworkzone
fdzworkzone

Reputation: 121

Ok, after testing more and more I found something that works. Sorry for making the Question without searching and testing more.

This is what has worked:

CMD /c start "" /B path\to\pythonw.exe path\to\manage.py runserver > nul ^& exit

Inside a .cmd file. Executing the file starts the Django dev webserver properly and a scheduled task that runs that .cmd file also start the server.

Upvotes: 2

Related Questions