| 1. |
Solve : Batch file compiled into exe doesn't work correctly...? |
|
Answer» Hey, I compiled my batch file into an exe and it does not work. When I run it, it just says "Press any key to continue. . ." (pause). I'm using Windows 7 Home Premium if that makes any difference.Quote from: Squashman on December 03, 2011, 06:11:52 PM With a 64 bit OS, java is installed in the the Program Files (x86) folder. Only the 32 bit Java goes there. Like many people I have both. 64 bit apps (e.g. 64 bit browsers) use the 64 Java in C:\Program Files. 32 bit apps use the 32 bit Java in C:\Program Files (x86). Anyhow, to the OP, and anyone INTERESTED in the topic of batch-to-exe converters, they are entirely unofficial, the quality of coding can be very variable, and they only support a subset of batch commands and features. If you really must have an .exe, use a different language e.g. FreeBasic. And another thing... these so called batch-to-exe "compilers" don't actually compile anything; they just take your batch and ENCLOSE it in a wrapper. When the resulting .exe file is run, it extracts the original batch to a folder somewhere and runs it, so it is quite possible that %0 expands to something you don't expect. Quote from: Salmon Trout on December 04, 2011, 01:42:36 AM When the resulting .exe file is run, it extracts the original batch to a folder somewhere and runs it, so it is quite possible that %0 expands to something you don't expect. Like this: Test.bat Code: [Select]echo off echo %%0 values: echo %%0 %0 echo %%~dpnx0 %~dpnx0 echo %%~d0 %~d0 echo %%~p0 %~p0 echo %%~n0 %~n0 echo %%~x0 %~x0 echo %%programfiles%% %programfiles% Run test.bat in 64 bit CMD session: Code: [Select]%0 values: %0 test.bat %~dpnx0 c:\Batch\Bat_To_Exe_Converter\Test.bat %~d0 c: %~p0 \Batch\Bat_To_Exe_Converter\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files Run test.bat in 32 bit cmd session: Code: [Select]%0 values: %0 test.bat %~dpnx0 C:\Batch\Bat_To_Exe_Converter\Test.bat %~d0 C: %~p0 \Batch\Bat_To_Exe_Converter\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files (x86) Compile test.bat to test.exe and run from same folder: Code: [Select]%0 values: %0 "C:\Users\UserName\AppData\Local\Temp\3564.tmp\Test.bat" %~dpnx0 C:\Users\UserName\AppData\Local\Temp\3564.tmp\Test.bat %~d0 C: %~p0 \Users\UserName\AppData\Local\Temp\3564.tmp\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files (x86) Run compiled test.exe from Drive Y: (a pen drive) Code: [Select]%0 values: %0 "C:\Users\UserName\AppData\Local\Temp\C0A3.tmp\Test.bat" %~dpnx0 C:\Users\UserName\AppData\Local\Temp\C0A3.tmp\Test.bat %~d0 C: %~p0 \Users\UserName\AppData\Local\Temp\C0A3.tmp\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files (x86) |
|