How to get program files environment setting from VBScript

31,052

Solution 1

Set wshShell = CreateObject("WScript.Shell")
WScript.Echo wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%")

Solution 2

To get Program Files (x86) use:

Set wshShell = CreateObject("WScript.Shell")
WScript.Echo wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%")
Share:
31,052
Jeremy
Author by

Jeremy

Software Developer

Updated on July 19, 2020

Comments

  • Jeremy
    Jeremy almost 4 years

    In a batch file you can use %PROGRAMFILES% to get the location of the program files directory, how do you do it in a VBScript?

  • Jeremy
    Jeremy over 14 years
    Nice, thanks. I have been resorting to reading the registry, but your answer is far better. Thanks.