win32api... another question: GetEnvironmentVariable("PATH")

Kevin Cazabon kcazabon at home.com
Tue Nov 16 00:15:55 EST 1999


Thanks... I'll have to go that route I guess.  I was hoping that if you
could access the SetEnvironmentVariable Win32 function, you could modify the
PATH system wide... it turns out not to be the case anyways, so the
os.environ route will work fine.

Thanks for the input...

Kevin.
Gordon McMillan <gmcm at hypernet.com> wrote in message
news:1269438868-3874906 at hypernet.com...
> Kevin Cazabon wrote:
>
> > Interesting... it doesn't work on Win98 for me (The exact statement
> > below...).
> >
> > Anyone have suggestions for Win95/98?
> >
> >
> > Kiss, Arpad <AKiss at GEOMETRIA.hu> wrote in message
> > news:01BF2F61.1D2B8DB0 at exchange1.geometria.hu...
> > > Hi,
> > >
> > > Kevin Cazabon <kcazabon at home.com> wrote in message
> > > news:<fcMX3.65012$Rx2.773564 at news1.rdc1.bc.home.com>...
> > > > I can't seem to get the win32api.GetEnvironmentVariable() function
to
> > > work
> > > > properly... am I not using it correctly by the following?
> > > >
> > > > path = win32api.GetEnvironmentVariable("PATH")
> > >
> > > It works for me on a Windows NT Workstation (sp5).
>
> First, why not use os.environ['PATH']?
>
> Second, while I'm on NT and 'PATH' and 'path' return the same
> answer (both the os and the win32api way), I had a bug report
> from someone on Win9x and the solution turned out to be:
>  try:
>    value = os.environ[key]
>  except KeyError:
>    value = os.environ[string.lower(key)]
>
>
>
> - Gordon
>
>






More information about the Python-list mailing list