Sign in to follow this  
Followers 0
cvocvo

Update @ProgramFilesDir after Disabiling filesystem redirection?

5 posts in this topic

#1 ·  Posted (edited)

I am running a 32bit app on 64bit machines sometimes, when I disable filesystem redirection, @ProgramFilesDir still shows C:\Program Files (x86).

Is there any way to update the @ProgramFilesDir to point at the location %programfiles% reflects once filesystem redirection is disabled?

Thanks

Edit: I couldn't figure out how to get the variables to update, but I wrote a work around:

If @OSArch = "X64" Then
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1) ;;Disables file system redirection for 32bit apps in 64bit land
$ProgramFiles = @ProgramFilesDir
$ProgramFiles = StringReplace($ProgramFiles, " (x86)", "")
Else
    $ProgramFiles = @ProgramFilesDir
EndIf
MsgBox(0,"", $ProgramFiles)
Edited by cvocvo

Share this post


Link to post
Share on other sites



I would strongly suggest NOT to disable filesystem redirection! This can can and will lead to chaos and confusion on OS-Level and for other programs.

Better write you'r own location wrapper, something like this:

if StringInStr(@OSArch,"64") then
    $ProgramFilesDir = stringleft(@WindowsDir,2) & "\Program Files"
Else
    $ProgramFilesDir = @ProgramFilesDir
endif

MsgBox(0,"",@ProgramFilesDir & @crlf & $ProgramFilesDir)

Share this post


Link to post
Share on other sites

The program files folder has nothing to do with filesystem redirection.

Hope this what you want:

If @OSArch = "X64" Then
    $ProgramFiles = EnvGet('ProgramW6432')
Else
    $ProgramFiles = @ProgramFilesDir
EndIf

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I would strongly suggest NOT to disable filesystem redirection! This can can and will lead to chaos and confusion on OS-Level and for other programs.

Better write you'r own location wrapper, something like this:

if StringInStr(@OSArch,"64") then
    $ProgramFilesDir = stringleft(@WindowsDir,2) & "\Program Files"
Else
    $ProgramFilesDir = @ProgramFilesDir
endif

MsgBox(0,"",@ProgramFilesDir & @crlf & $ProgramFilesDir)

From what I've read on the forums here it's only disabled for my application and there isn't any need to switch it back.

If this isn't the case, how would I switch it back on?

Edit: I want to use this so it uses the 64bit versions of regedit and cmd. I'm doing some reg exporting, batch file creation, and some other stuff that makes 64bit versions of those way easier to work with.

Edited by cvocvo

Share this post


Link to post
Share on other sites

From what I've read on the forums here it's only disabled for my application and there isn't any need to switch it back.

Me bad :blink:...

Wow64DisableWow64FsRedirection: "Disables file system redirection for the calling thread. File system redirection is enabled by default."

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0