Archive: x64 SysWOW64 and running app


x64 SysWOW64 and running app
Hi,

As I see all 32-bit apps are forwarded in x64 to the SysWOW64 folder for backward compatibility but I can't understand how to run an exe located inside SysWOW64?

I included x64.nsh and I tried Exec, ExecWait, ExecShell "open" and even creating an shortcut but all those always point to system32 folder instead SysWOW64

I also tried ${EnableX64FSRedirection} but the same issue. Can anyone here let me know how to run an exe app located inside SysWOW64?


If you want to open a file/application from SysWOW64 (The 32bit System folder on a 64bit machine. Yes, blame MSFT for the naming - it's "System Windows32 on Windows64"), from a 32bit application (such as NSIS currently), you should actually be fine with Exec, ExecWait, etc.

If you want to open a file/application from System32 (The 64bit System folder on a 64bit machine), that's when you either use ${DisableX64FSRedirection} before the Exec/ExecWait/etc. and ${EnableX64FSRedirection} afterward, -or-, instead of specifying System32, use SysNative. I.e. `Exec "$WINDIR\SysNative\YourApp.exe"`. Note that SysNative is only available from Vista and up. There's a special hotfix for XP64, but you can't rely on that being installed at all.

I suggest testing with a simple set of text files with the content indicating in which folder they actually are (i.e. "This text file is in SysWOW64 - the 32bit System directory"), so you can easily see if filesystem redirection is messing with things.


Hi Animaether

Thank you for your solution! I will do some tests using your suggestion.


My installer is 32bit and install some files using $SYSDIR which redirect installation to SysWOW32. This is OK until I try to run using Exec, ExecWait or even ExecShell "open" an exe file from SysWOW32. This never works as when I use Exec "$SYSDIR\folder\myapp.exe" this will fail as this will try to start myapp.exe from Windows\system32\folder\myapp.exe instead Windows\SysWOW64\folder\myapp.exe

This is the same even if I use ${EnableX64FSRedirection} before to SetOutPath $SYSDIR\folder
I can't use SysNative as I need my app compatible also with XP.

Please let me have a working solution if any.

Thanks!


well.. as far as I can tell, this should work 'as is' without anything special needed.

Just to make 100% sure.. you -want- your application to be in SysWoW64 and you -want- to run it from that location.. correct?

If so.. here's my test set... one small installer that simply reports where it was originally run from:


RequestExecutionLevel admin
OutFile "test.exe"
Section
MessageBox MB_OK "application run from $EXEDIR"
SectionEnd


And one to place it in SYSDIR and run it from there:

!include "LogicLib.nsh"
!include "x64.nsh"
OutFile "test_system32.exe"
RequestExecutionLevel admin
Section
${Unless} ${RunningX64}
MessageBox MB_OK "You are not running on a 64bit machine - no point in running these tests."
Abort
${EndUnless}

MessageBox MB_OK "Running 32-bit (SysWOW64) tests"
SetOutPath "$SYSDIR"
MessageBox MB_OK "Output path is now: $SYSDIR"
File "test.exe"
MessageBox MB_OK "Test executable written to: $SYSDIR . Please verify (check for '$WINDIR\SysWOW64\test.exe')."
MessageBox MB_OK "Testing 'Exec $$SYSDIR\test.exe'"
Exec "$SYSDIR\test.exe"
MessageBox MB_OK "Testing 'ExecWait $$SYSDIR\test.exe'"
ExecWait "$SYSDIR\test.exe"
MessageBox MB_OK "Testing 'ExecShell $$SYSDIR\test.exe'"
ExecShell "" "$SYSDIR\test.exe"
MessageBox MB_OK "32-bit Tests concluded."
SectionEnd

Thanks again for your solution!

Seems that $SYSDIR always point to Windows\system32 when Exec, ExecWait or ExecShell are used.

What I can see is that if I use "$WINDIR\SysWOW64" instead "$SYSDIR" then everythings works as expected. Now my questions are:

1. Can be there any issue with Non English OS if I use "$WINDIR\SysWOW64" ? I mean this path is the same for all languages OS or on some languages this "SysWOW64" is renamed/transalted?

2. Finally, can I meet any compatibility issue using "$WINDIR\SysWOW64" instead "$SYSDIR" ? It is recommended to use it like that or not? As seems a very easy way to fix that x64 redirection issue...


Originally posted by underline
...Seems that $SYSDIR always point to Windows\system32 when Exec, ExecWait or ExecShell are used.

What I can see is that if I use "$WINDIR\SysWOW64" instead "$SYSDIR" then everythings works as expected...
Are you using the x64.nsh include with the ${DisableX64FSRedirection} macro run prior to executing? If so then that's why you are seeing this behavior.

If not then I have a few other theories:

Zinthose, thank for your reply!

I'm using x64 (64-bit) edition XP and 7, I had included x64.nsh and I disable and enable redirection befor Exec but my mistake was that I do that before and after ExecShel "open" shortcut (my exe is run through an shortcut) instead disable and enable x64 redirection before and after creation of that shortcut. After I do it like that now works.