Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Executing batch file with different extension

I wonder if there's a way to make ttcle execute a batch name with an arbitrary file exetension, let's say batch.tccle

The need arise since I have a big reservoir of old batches written for 4nt 4 to 6 which sometimes disfunction in newer versions. Then I envisioned a simple way of "versioning" by assignin .btm (or .4nt) to 4nt and .tccle to tccle. That way it would be obvious what version they were written for also when seeing files from the file system.
Sure I could add a small header to load the right interpreter, or even revise each batch to work correctly with new versions of the interpreter, but they are a LOT of batches and I don't use them very often.

Back to the question: when I try to execute batch.tccle the interpreter asks windows what to do with it.
It seems that .bat .cmd .btm .exe .com and the other executables extensions are hardcoded into the command processor. Am I Right? Is there a way to circumvent it?

Thank you
 
Look at the ASSOC and FTYPE commands, executable extensions, and PATHEXT. But your best bet is to just modify them as you use them. The "disfunctions" you encounter can sometimes be addressed by certain OPTION settings.

I don't believe you can invoke an arbitrary file as a batch script. However, you could create a "handler". The following is untested but should give you a start.

Code:
assoc .4nt=4nt.Batch
ftype 4nt.Batch=c:\4nt\4nt.exe /c 4ntscript.btm %*
4ntScript.btm:
iff %# == 0 then
  echo error missing argument
  quit
endiff
set f=%@unique[]
copy %1 %f
shift
ren %f *.btm
set f=%@replace[.tmp,.btm,%f]
call %f %$
del /q %f
 
Look at the ASSOC and FTYPE commands, executable extensions, and PATHEXT. The "disfunctions" you encounter can sometimes be addressed by certain OPTION settings.
I know. I didn't mean to say JPSoft doesn't care on retro compatibility. My batches are so old that they still use ^ as command separator...

I don't believe you can invoke an arbitrary file as a batch script.
That's a pity. Is there a technical reason? Never noticed this limitation. Also looked for a way of inputing the batch via redirection and that's also missing.

However, you could create a "handler". The following is untested but should give you a start.

Thank you! I also tought of a handler, but the on-the-fly rename operation seems necessary and I'm not going to use it.
BTW I tried to make windows explorer (W7) understand double extensions (like batch.tccle.btm) but it doesn't want to. Even if I can write the correct double extension in the classes root of the registry, then explorer wouldn't match it as it extracts only the .ext part of the filename (understandably it doesn't do reverse match from the registry to the filename).

I hope that "versioning" like in some *nix processors and arbitrary file execution will be taken into consideration some day in the future.

But your best bet is to just modify them as you use them.
I think you are right.
Maybe I will resurrect ".bat" extension as a bridge...
Or maybe I will be able to write a one-liner version selector and add it automatically to all the batches. Would you raccomand %_4VER o %_BUILD?

Thank you for the support!
 
You could just copy the base name and use it instead of @UNIQUE.

Code:
assoc .4nt=4nt.Batch
ftype 4nt.Batch=c:\4nt\4nt.exe /c 4ntscript.btm %*
4ntScript.btm:
Code:
iff %# == 0 then
  echo error missing argument
  quit
endiff
copy %1 %@name[%1].btm
call %@name[%1].btm %2$
del /q %@name[%1].btm
 
I had a look at this idea some decade ago. The idea was that you could set up some sort of environment, and then turn some sort of extension into a batch, eg ".bzp". It did not work as well as i hoped, and in the end, i wrote my own command processor for .bzp or whatever.

The basic idea though, would be to have some sort of 'run' command, that you can run a file as something of a different extension. For example, if you did 'run .bmp c:\logo.sys, it would load logo.sys following the file association for .bmp. For batch files, you would then do something like "run .cmd Myapp.bzp params", and it would be much like running "myapp.cmd params",

Given that a good number of exe files are already distributed like this, it's not as perverse as first seems. Did you know, you can take xcopy32.mod from Windows 98, and rename it xcopy.exe, and you save 3½ kB, which is important on a floppy? It's just an exe hiding as a mod, and you could have cmd files hiding as bzp waiting for the right environment to wake them up?
 
You could just copy the base name and use it instead of @UNIQUE.

Thank you Scott, but for me the copy operation is a no-go.
If only tccl wasn't so stubborn and picky about to what to execute :)
Most programs would ignore extensions of files specified on the command line.
Or even a function backdoor or command line switch would do.
But seems it has never been a big request.
 
I had a look at this idea some decade ago. The idea was that you could set up some sort of environment, and then turn some sort of extension into a batch, eg ".bzp". It did not work as well as i hoped, and in the end, i wrote my own command processor for .bzp or whatever.

The basic idea though, would be to have some sort of 'run' command, that you can run a file as something of a different extension. For example, if you did 'run .bmp c:\logo.sys, it would load logo.sys following the file association for .bmp. For batch files, you would then do something like "run .cmd Myapp.bzp params", and it would be much like running "myapp.cmd params",

Given that a good number of exe files are already distributed like this, it's not as perverse as first seems. Did you know, you can take xcopy32.mod from Windows 98, and rename it xcopy.exe, and you save 3½ kB, which is important on a floppy? It's just an exe hiding as a mod, and you could have cmd files hiding as bzp waiting for the right environment to wake them up?

Thank you for sharing! But as I understand this wouldn't work with tccle (or any JPsoft command processor) since the first step of "execute" algoritm of tccle (or 4nt) is examining the extension: if it is cmd or btm or bat then process it internally, otherwise relay on to windows file association.
First time I associated .4nt files with "4nt.exe /c" I just obtained infinite loops :)
 
I wrote my own command processor to do it, though. I was just saying that it would had been nice if you could do it like i suggested.

Still, i don't think tccle supports extproc.
 
Back
Top
[FOX] Ultimate Translator
Translate