So I wrote a batch file to convert clients over to a cloud service and I'm seeing some weird behavior from it.
So this basically looks for a specific folder and whether or not it exists it uses GOTO to move on. When I compress this using WinRAR into a SFX and instruct it to run the batch file it NEVER detects the folder, however, when I run the batch file itself, it ALWAYS detects the folder, whether its there or not. I've been trying to figure this out for a few days now and I just don't understand why this is happening.
@ECHO Off
CD %~dp0
Goto DisableLocal
:DisableLocal
IF EXIST "%ProgramFiles%\Server\" (
GOTO Server
) ELSE (
GOTO Config
)
For 32-bit applications executed on 64-bit Windows the environment variable ProgramFiles is set to value of environment variable ProgramFiles(x86) by Windows as Microsoft explains in MSDN article WOW64 Implementation Details.
The WinRAR SFX archive is created obviously using the x86 SFX module. The SFX archive could be also created using x64 SFX module, but then this SFX archive can be executed only on Windows x64.
The batch file is executed with 32-bit
cmd.exe
in 32-bit environment if the x86 SFX module is used on creating the archive.So better is to adapt the batch code and add a detection for 32-bit execution on 64-bit Windows.
I have the same problem, I'm trying this way, but not sure if will work on a Windows 32 bits.