> Date: Mon, 19 Nov 2007 02:18:12 +0000 (UTC)
> From: Charlie <[EMAIL PROTECTED]>
> Subject: [python-win32] want to leave DOS console at any target dir
> To: python-win32@python.org
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset=us-ascii
>
> When launching a python script from a DOS console,
> I can not find a way to leave the DOS console at a working directory
> other than the initial working directory.
>
> os.chdir only seems to work for the python script context, not the DOS 
> context.
>
> I guess this amounts to a work-around for no "os.fchdir" function in 
> python for
> Windows.
>
> My current approach (which is an eye-sore) is to:
> 1) Launch a BAT file
> 2) The BAT file launches my python script
> 3) the python script creates a 2nd BAT file with a "CD c:\xxx\yyy" command
> 4) The 1st BAT file calls the 2nd BAT file when the python script 
> terminates.
>
> Yikes.
>
> Please tell me there's something better.

That's "just the way it works".  An executable is created with an initial 
current directory and can only change its own current directory.  The parent 
executable has its own current directory and it can't be changed by its 
child processes.  The parent has to set up a method for the child to tell it 
when it wants the parent to change, which is what you've set up in the 
scenario you described.

-Mark 

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to