Is it possible to change the working directory of the Windows command line through a Python script?
eg.
>> cd
>> c:\windows\system32
>> make_decision_change_dir.py
>> cd
>> c:\windows
I tried several things that do not work:
import os
os.chdir(path)
import os, subprocess
subprocess.Popen("chdir /D \"%s\"" %path, shell=True)
import os, subprocess
subprocess.Popen("cd \"%s\"" %path, shell=True)
import os, subprocess
subprocess.Popen("CD=\"%s\"" %path, shell=True)
As I understand and observe these operations, we change the current working directory of the processes - this is a Python process, not a request for its execution.
Thanks.
UPDATE
The path I would like to change is dynamic (depending on what project I'm working on, the full path to changing the assembly location), so I wanted to encode the solution in Python, and not hack the Windows batch file.
UPDATE
I ended up hacking a batch file together to do this; (Thanks to everyone.
source
share