0

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?

Ciro García
  • 601
  • 5
  • 22

1 Answers1

2

Use the PROGRAMFILES environment variable:

>>> from os import environ
>>> environ['PROGRAMFILES']

'C:\Archivos de Programa'
bool3max
  • 2,748
  • 5
  • 28
  • 57
  • "C:\Program Files" should exist in Windows Vista and later. If "C:\Archivos de Programa" exists, it should be a symlink or bind mountpoint (aka junction) for the real name. Check `import pathlib;` `print(pathlib.Path('C:/Archivos de Programa').resolve())`. – Eryk Sun Jul 23 '20 at 03:08