Python change the working directory for an exe opened with startfile
Posted
by
Saulpila
on Stack Overflow
See other posts from Stack Overflow
or by Saulpila
Published on 2011-06-26T23:52:20Z
Indexed on
2011/06/27
0:22 UTC
Read the original article
Hit count: 150
In python i'm using the os.startfile command to start a windows executable that does especific stuff in its own folder, the python code is running from another folder, so when I start the file, it starts in the python script's working directory, but it has to start in its own directory. I've tried to use os.chdir(path) to change the working directory, but it fails, the file still not runs in it's own folder. I thought maybe there is a command like shortcut's "Start in" line. I've searched everywere, but not success. The only solution comes to my mind is to create a shortcut and add the "start in" line, then launch the shortcut, but that is very impractical.
© Stack Overflow or respective owner