Welcome!

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

SignUp Now!

assoc/ftype

Oct
382
2
I have the following set up via assoc and ftype

.txt=kedittxtfile
kedittxtfile="c:\tools\kedit.bat" "%1" "%2" "%3" "%4" "%5"

when I type at the cmd.exe prompt foo.txt

the bat file is executed and the program starts, but when I type

foo.txt at the tcc prompt I get

TCC: (Sys) The system cannot find the file specified.
"c:\tools\kedit.bat %1 %2 %3 %4 %5"

what did I miss setting this up? Thanks
 
I think you need to include the complete path to CMD.EXE (or TCC.EXE) before the batch file name. Including a /C probably wouldn't hurt, either.
 
Here's what Microsoft CoPilot said in regards to your question.

Not tested.

Joe

The association itself is fine — what’s biting you is how TCC parses the ftype command string, not a missing assoc or ftype setting.

What’s actually happening
  • cmd exe hands the ftype command line to CreateProcess() almost verbatim.
  • TCC pre‑parses the command string before Windows ever sees it.
  • Because your ftype definition contains embedded quotes, TCC treats the entire string as a literal executable name instead of a command + arguments.

That’s why TCC reports:

Code:
The system cannot find the file specified. 
`"c:\tools\kedit.bat %1 %2 %3 %4 %5"`

It’s trying to execute that entire quoted string as a filename.

The fix: remove the quotes from the executable path
TCC does not require quotes around the batch file path in an ftype definition unless the path contains spaces — and even then, quoting must be done carefully.

Your path has no spaces, so define it like this:

Code:
ftype kedittxtfile=c:\tools\kedit.bat "%1" "%2" "%3" "%4" "%5"

That works in both cmd exe and TCC.

Why this works
  • TCC correctly identifies c:\tools\kedit.bat as the executable
  • %1-%5 are passed as arguments
  • Quoting is applied only to parameters, not the command itself

This behavior is documented in JP Software’s notes on parameter parsing and quoting in TCC JP Software.

If the batch file path does contain spaces
You must wrap the call through cmd /c call so TCC doesn’t misinterpret it:

Code:
ftype kedittxtfile=cmd /c call "c:\tools\kedit.bat" "%1" "%2" "%3" "%4" "%5"

This is the same workaround used for quoted batch associations in Windows generally Stack Overflow.

Recommended best practice (cleaner and future‑proof)
Inside kedit.bat`, just use %*`:

Code:
@echo off
rem your logic here

Then define:

Code:
ftype kedittxtfile=c:\tools\kedit.bat "%*"
This avoids argument‑count limits and quoting edge cases entirely.

Summary
  • Nothing is “missing” — this is a TCC parsing difference
  • Do not quote the executable path unless absolutely required
  • Quote parameters, not the command
  • Use %* inside the batch file for robustness
 
Hmmm! I wonder about that. What if the fully-qualified batfile name had a space in it?
 
Back
Top