7

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
  • 44,950
  • 68
  • 206
  • 332

2 Answers2

17
Set wshShell = CreateObject("WScript.Shell")
WScript.Echo wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%")
Jonas Elfström
  • 30,834
  • 6
  • 70
  • 106
  • Nice, thanks. I have been resorting to reading the registry, but your answer is far better. Thanks. – Jeremy Dec 12 '09 at 18:05
7

To get Program Files (x86) use:

Set wshShell = CreateObject("WScript.Shell")
WScript.Echo wshShell.ExpandEnvironmentStrings("%PROGRAMFILES(x86)%")
Bizmarck
  • 2,663
  • 2
  • 33
  • 48