Daily Gem: Quickly and temporarily bypass Vista / Win 7 file redirection in your VB6 Apps

How to quickly get around redirection in your VB6 app:

a) You wish to check for or launch program in “c:\Windows\System” folder (Without redirection to “c:\Windows\SysWow64”)

Use the “\SysNative” path!

Public Const CSIDL_WINDOWS = &H24
GetSpecialFolder(CSIDL_WINDOWS) & "\SysNative\"
Note, the GetSpecialFolder function appears in many other plaes, like this.

For example:

z = shell(GetSpecialFolder(CSIDL_WINDOWS) & "\SysNative\<64-bit appname>.exe")

b) Check for program in “c:\Program Files” without redirection to “c:\Program Files (x86)”

Abuse the “\SysNative” path!

GetSpecialFolder(CSIDL_WINDOWS) & "\SysNative\..\..\Program Files\"

For example:

z = shell(GetSpecialFolder(CSIDL_WINDOWS) & "\SysNative\..\..\Program Files\<64-bit appname>.exe")

This leads to the question, how to get “Program Files” directory name?


ProgramFilesFolder$ = Environ("ProgramW6432")
ProgramFilesFolder$ = Mid(ProgramFilesFolder$, InStr(ProgramFilesFolder$, "\") + 1)
z = shell(GetSpecialFolder(&H24) & "\SysNative\..\.." & ProgramFilesFolder$ & "\<64-bit appname>.exe")