Activating Batch Files from Python

Tim Roberts timr at probo.com
Fri Apr 21 01:33:39 EDT 2006


"Jeff Groves" <mikelemmer6 at yahoo.com> wrote:
>
>I'm writing a launcher that should do the following:
>
>1. Activate a .bat file to set environmental variables.
>2. Start 3 programs, using said environmental variables as arguments.
>
>However, I can't get the environmental variables to stick because all
>of Pythons' system start/open functions split off into their own little
>subshells, therefore the .bat file doesn't affect the main shell.
>
>How can I use the .bat file to set environmental vars from Python?

One very real possibility is to parse your .bat files by hand, and make the
changes to your os.environ.  Your subprocesses inherit that.

.BAT files are easy to parse, especially if they're just a bunch of 'set'
statements.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list