William Troup
William Troup

Reputation: 13141

Get windows/system folder location in Python

How would I go about getting the Windows/System folder paths in python? I need to be able to read from an INI that gets written to the Windows directory.

Upvotes: 3

Views: 8148

Answers (1)

carlpett
carlpett

Reputation: 12613

Use the environment variable %WINDIR%.

import os
winpath = os.environ['WINDIR'] + "\\System\\"
inifile = open(winpath + filename)

Upvotes: 9

Related Questions