[Python-au] Environment vars

Mike Dewhirst miked at dewhirst.com.au
Thu Aug 18 01:47:27 CEST 2005


Grant McDonald wrote:
> Not entirely sure,
>  
> The docs say you should modify os.environ directly since it automatically
> calls putenv, but as you stated on WinXP and as you say it doesn't seem to
> work.  I guess putenv may not be supported on WinXP.
>  
> If you want a reliable way of modifying the environment on WinXP use the
> registry (unfortunately platform specific):

I'd prefer to stay platform neutral. I think I'll detect os.name and 
scribble out a batch file to set a couple of vars if it is 'nt'.

Thanks

Mike

>  
> System environment ->
>  
> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
> Manager\Environment
>  
> User environment ->
>  
> HKEY_CURRENT_USER\Environment
>  
>  
> Regards,
>  
> Grant McDonald
>  
>  
> 
> -----Original Message-----
> From: python-au-bounces at python.net [mailto:python-au-bounces at python.net]On
> Behalf Of Mike Dewhirst
> Sent: 17 August 2005 21:28
> To: python-au at python.net
> Subject: [Python-au] Environment vars
> 
> 
> I'm having difficulty inserting a couple of vars into the environment from
> within a script. 
> 
> os.putenv(varname, value) doesn't seem do it.
> 
> The code doesn't barf but (in Windows XP) the set command doesn't indicate
> it actually happened. I haven't tried it with Linux.
> 
> Is there a trick to it?
> 
> TIA
> 
> Mike
> 
> 
> 




More information about the python-au mailing list