Page 1 of 1

Pass parameters to bat compiled to exe.

Posted: 07 Nov 2016 07:24
by JuanMa777
Hi, I have an script that requiere parameters to complete your function.
Some like,

Code: Select all

echo %1

and then, c:\>script.bat Maradona!
but more complex.
This is simple, the question is that I need to compile to exe my script to hide the content, and when I do this I can't no more pass it the parameters.
c:\>script.exe Maradona! ---> error
How can I solve this?
Thanks.

Re: Pass parameters to bat compiled to exe.

Posted: 07 Nov 2016 08:02
by aGerman
Batch cannot be compiled. What you get is something like an installer or self-extracting archive. As soon as run the exe file it will unpack your plain batch script somewhere into the %temp% folder and run it there. So forget about hiding the content. Everything is perfectly visible during the runtime.

Exactly for reasons like you mentioned I'd call those tools bloody bulls***. Depending on the used tool parameters are not available, the working directory is wrong, it runs the script in WOW64 compatibitility mode, antivirus software fires false positives, or whatever side effects you can think of. If you have a batch script run it as batch script. If you need a compiled exe file use a compilable language.

Steffen

Re: Pass parameters to bat compiled to exe.

Posted: 07 Nov 2016 08:21
by JuanMa777
Thanks Steffen, very light, I'll try another solution.
Regards.