Activating Batch Files from Python

EShames NethanO at SPdogdiniAM.com
Thu Apr 20 17:51:38 EDT 2006


On 4/18/2006 11:39 PM, Jeff Groves 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?
> 

Resource Kit has SETX, but better is SETENV by Vincent Fatica
  http://barnyard.syr.edu/~vefatica/

C:\_Utils>setenv /?
  SETENV syntax:

   To set or change the value of a variable:

      User environment:           setenv -u name value        (also /u)
      Machine environment:        setenv -m name value        (also /m)
      Default user environment:   setenv -d name value        (also /d)
      Volatile environment:       setenv -v name value        (also /v)

   To display a variable:     setenv -u|-m|-d|-v name

   To delete a variable:      setenv -u|-m|-d|-v name -delete   (also 
/delete)

   To display an environment: setenv -u|-m|-d|-v

   Use double-quotes around values containing spaces.

   If a variable name or value is to CONTAIN a double-quote,
   escape that double-quote as \"

   Return codes: 0 = success        1 = variable not found
                 2 = access denied  3 = other error
                 4 = SETENV has shown this syntax message

   Requested output goes to STDOUT; help and error messages to STDERR.



More information about the Python-list mailing list