%SystemDrive%

Carsten Haese carsten at uniqsys.com
Wed Feb 15 14:17:25 EST 2006


On Wed, 2006-02-15 at 14:07, Todd Whiteman wrote:
> Another hack:
> drive = os.popen("echo %SYSTEMDRIVE%").readline().strip()
> 
> rtilley wrote:
> > Is there a proper way to get this variable from Windows? I know it's in 
> > the registry, but I'd rather not go there. I could not find a CSIDL 
> > shell constant for it either. I've been doing this:
> >
> > os.chdir('/')
> > sys_drive = os.getcwd()
> > print sys_drive
> > C:\
> >
> > This seems too much of a hack and maybe not 100% right all of the time. 
> > How could it be done better?
> >   

Is there a reason why os.environ['SYSTEMDRIVE'] shouldn't work?

Hope this helps,

Carsten.





More information about the Python-list mailing list