Skip to content Skip to sidebar Skip to footer

Start Cmd And Run Multiple Commands In The Created Cmd Instance

I am trying to start cmd window and then running a chain of cmds in succession one after the other in that cmd window. something like start cmd /k pipenv shell && py manage

Solution 1:

When issuing commands chaining them, the system sees it as first command && second command

I your case, you are giving first command to be start cmd and second command py manage.py which will do exactly that, you are issuing a cmd in a new window and if that is successful, it will initiate py in the same window you started. You should therefore escape the & with a caret in order to pass through the chain to the second command window and not initiate the chain in the current window:

start cmd /k pipenv shell ^&^& py manage.py runserver

Keep in mind that you could also just add both commands into a batch file as:

pipenv shell
py manage.py runserver

and launch it as:

start "" mybatch.cmd

Solution 2:

Your py manage.py runserver command calling python executor in your major environment. In your case, you could use pipenv run manage.py runserver that detect your virtual env inside your pipfile and activate it to run your command. An alternative way is to use virtualenv that create virtual env directly inside your project directory and calling envname\Scripts\activate each time you want to run something inside your virtual env.

Post a Comment for "Start Cmd And Run Multiple Commands In The Created Cmd Instance"