0

When I run the command set programfiles in the command prompt, I get

ProgramFiles=C:\Program Files (x86)
ProgramFiles(x86)=C:\Program Files (x86)

However, the following code in python

import os
print os.getenv("programfiles")

or

msgbox %A_ProgramFiles% and %ProgramFiles%

in Autohotkey

or

$env:ProgramFiles

in PowerShell

all results in C:\Program Files

I cannot understand why I'm getting different results for the Program Files Environment Variables in Windows

Ishan
  • 3,931
  • 11
  • 37
  • 59

1 Answers1

2

What you see is the difference between a 32-bit and 64-bit application.

32-bit cmd.exe (%SystemRoot%\SysWOW64\cmd.exe)

C:\>set programfiles
ProgramFiles=C:\Program Files (x86)
ProgramFiles(x86)=C:\Program Files (x86)

64-bit cmd.exe (%SystemRoot%\System32\cmd.exe)

C:\>set programfiles
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)

32-bit powershell.exe (%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe)

PS C:\> dir env:\programfiles*

Name                           Value
----                           -----
ProgramFiles(x86)              C:\Program Files (x86)
ProgramFiles                   C:\Program Files (x86)

64-bit powershell.exe (%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe)

PS C:\> dir env:\programfiles*

Name                           Value
----                           -----
ProgramFiles(x86)              C:\Program Files (x86)
ProgramFiles                   C:\Program Files
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206