Jump to content

Update @ProgramFilesDir after Disabiling filesystem redirection?


Recommended Posts

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
Link to comment
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)
Link to comment
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)

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
Link to comment
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."

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...