Forum Discussion
Adrian1595
Jul 17, 2021Brass Contributor
BAT file to open cmd prompt, change directory and execute python at that changed folder on Win 10?
I need to open one command prompt window on windows 10, change directory to a specific folder on that same cmd window and get python prompt on that same command prompt window executing python.exe at ...
- Jul 18, 2021
@echo off PushD E:\myDir\script Echo Python prompt in the folder %cd% :: If you want to be sure remove the following comment :: c:\path\to\python\python.exe -c "import os ; cwd=os.getcwd();print(cwd)" cmd.exe /k c:\path\to\python\python.exe
PushD change disk and folder (equivalent to cd E:\myDir\script & E:)
If python is non in the path enviroment variable you need the full path to python exe ...
gastone
Jul 18, 2021Brass Contributor
@echo off
PushD E:\myDir\script
Echo Python prompt in the folder %cd%
:: If you want to be sure remove the following comment
:: c:\path\to\python\python.exe -c "import os ; cwd=os.getcwd();print(cwd)"
cmd.exe /k c:\path\to\python\python.exe
PushD change disk and folder (equivalent to cd E:\myDir\script & E:)
If python is non in the path enviroment variable you need the full path to python exe ...
RobertWatson
May 05, 2024Copper Contributor
Got the same.. this helped