pythonwindowspathprogram-files

Get language variants of C:\Program Files


I am about to distribute an app, and I am creating an installer. I know that apps in windows go to C:\Program Files but I am also aware that the folder changes its name depending on the language, for example, in spanish it is C:\Archivos de Programa

This is quite tricky because I do not want to have to detect the language of windows and then having to create a different variable for each path in a different language. Is there any way I can get the name of that folder from python so I can just use that to create a single path?


Solution

  • Use the PROGRAMFILES environment variable:

    >>> from os import environ
    >>> environ['PROGRAMFILES']
    
    'C:\Archivos de Programa'