0

my problem is that when I convert a .bat file to a compiled .exe file using the software "Bat to exe converter v1.6" does not work at 100%. The .bat works at 100% when I use it, but not the .exe.

The .bat file in question has two conditional expressions, but the processor architecture's one is not working:

rem the first is checking that, and its working 100%

IF %SistemaOp% == XP (goto winxp) else (goto winseven)

:winxp

    echo xp

rem this is the part that it's NOT working. It never goes to 64 bit part

    IF  %PROCESSOR_ARCHITECTURE% == x86 (goto winxp86) else (goto winxp64)
    :winxp86
            echo xp 32 bit
    :winxp64
            echo xp 64 bit
:winseven
    echo seven

rem this is the other part that it's NOT working. It never goes to 64 bit part

    IF  %PROCESSOR_ARCHITECTURE% == x86 (goto winseven86) else (goto winseven64)
    :winseven86
    echo seven 32 bit
    :winseven64
    echo seven 64 bit
user3108594
  • 225
  • 2
  • 5
  • 13
  • 1
    Most likely the problem is that the exe is a 32-bit executable, so it cannot tell if the processor is 64-bit. – nneonneo Feb 28 '14 at 19:48
  • Related question that may help...http://stackoverflow.com/questions/1738985/why-processor-architecture-always-returns-x86-instead-of-amd64. – aphoria Feb 28 '14 at 19:51
  • ok, so how could I compile a .bat to .exe in 64-bit application? – user3108594 Feb 28 '14 at 19:55

2 Answers2

0

It is probable your converter i use Advanced bat to exe It is a good compiler and it also adds it own advanced commands. Give it a go. It does 32bit and 64bit.

09stephenb
  • 9,358
  • 15
  • 53
  • 91
0

The solution was changing the %PROCESSOR_ARCHITECTURE% part to this:

@echo off

SET ARCHITECT=HELLO reg query "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /v

PROCESSOR_ARCHITECTURE | find "ARCH" | FINDSTR /L "86" > NUL

IF %ERRORLEVEL% EQU 0 (SET ARCHITECT=32 bit) ELSE (SET ARCHITECT=64 bit)

echo %ARCHITECT%

pause

user3108594
  • 225
  • 2
  • 5
  • 13