I am trying to write a python script that will change my cwd
to the desired directory. I was not able to do this task directly from python so I wrote a simple batch
script to do that.
Changedir.bat
@echo off
chdir /D F:\cygwin\home\
If I execute the above script directly in my cmd
it works fine but if I try to execute it with a python script nothing happens. My cwd
remains same.
PythonScript.py
import shlex,subprocess
change_dir = r'cmd.exe /c C:\\Users\\test.bat'
command_change = shlex.split(change_dir)
subprocess.call(command_change)