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?

2 Answers 2

17
Set wshShell = CreateObject("WScript.Shell")
WScript.Echo wshShell.ExpandEnvironmentStrings("%PROGRAMFILES%")
Sign up to request clarification or add additional context in comments.

1 Comment

Nice, thanks. I have been resorting to reading the registry, but your answer is far better. Thanks.
7

To get Program Files (x86) use:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.