Midas wrote:
m^(2) wrote:
"Compiled" batches have no bug-free way to store relative paths. Therefore I recommend not to use it. Batches themselves are better.
Looking into this: what about environment variables or temporary text files?
Wow, an old thing.
I don't know what do you mean by "environment variables or temporary text files". To do relative paths right, you'd have to first know the directory in which your batch is placed and with most compiled batches you have no way to get it, %cd% can be anything and %~dp0 is some file in temp.
Anyway, I remember seeing a "compiler" that hacked the issue, after a quick look it looked OK.
It took your batch and built another from it; one that did a 'shift' and run your code.
The exe launcher would extract the script to text (like all batch 'compilers' do) and execute from there, but providing own exe path (or something like that) as the first parameter and passing parameters that it got after it.
This way, the user batch had exe name as %0 and all other parameters after it, about the same as it would get by not being "compiled" in the first place, so you could use %~dp0 and have it working. Still it didn't work correctly with some fun stuff (like self-modifying scripts), but for 99% of users should be good enough.
So if you really want to "compile", I recommend using that "compiler".
You may ask how is it called...I don't know, it was a brief look years ago. Others might be able to help. I think sb. from here showed me the program.