Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the ${env:ProgramFiles(x86)} Powershell variable contain on a 32bit/x86 system?

Tags:

Simple question:

If I use the ${env:ProgramFiles(x86)} variable in a PowerShell script on a 32-bit system does it return "C:\Program Files" or is it undefined?

On a x64 system it will be mapped to "C:\Program Files (x86)" when running in both x64 and x86 mode. I don't have a 32bit system to test on, but I hope that it will be mapped to the "C:\Program Files" folder so I can use it to refer to x86 programs on any system.

like image 618
Greg Bray Avatar asked Sep 25 '13 21:09

Greg Bray


People also ask

How do I read an environment variable in PowerShell?

Environment variables in PowerShell are stored as PS drive (Env: ). To retrieve all the environment variables stored in the OS you can use the below command. You can also use dir env: command to retrieve all environment variables and values.

Where are PowerShell environment variables stored?

In PowerShell, environment variables are stored in the Env: "drive", accessible through the PowerShell environment provider, a subsystem of PowerShell. This isn't a physical drive, but a virtual file system. Environment variables convey information about your login session to your computer.


1 Answers

${env:ProgramFiles(x86)} is not defined on a 32-bit machine. You can test against $null to verify that.

like image 66
Keith Hill Avatar answered Oct 19 '22 07:10

Keith Hill