Fail to extract PROGRAMFILES(X86) environment variable using powershell
After long time, today i wasted almost 30 minutes on a stupid mistake, i tried to have a PS script that will run a program from “%ProgramFiles(X86)\A-Program.exe”
So i tried using “$Env:PROGRAMFILES(X86)\A-Program.exe” and it failed coz it said its trying to run from: “c:\program files(X86)\A-Program.exe” and directory doesn’t exist
so after digging i saw that the problem is powershell took the first part of the string and extracted the programfiles environment variable :( (there was no space between it and the (X86) ), than again how was he suppose to know…
Solution was to use: “${env:PROGRAMFILES(X86)}\A-Program.exe”
Hope it will save you some time
Fail to extract PROGRAMFILES(X86) environment variable using powershell
Reviewed by Ran Davidovitz
on
4:07 PM
Rating:
No comments:
Post a Comment