I have a TCL/TK app on Windows. What is the best way to open a file with its associated program? For example, I am generating a PDF, and I want it to open automatically.
There's an example to see what the association is on the registry man page
package require registry
set ext .tcl
# Read the type name
set type [registry get HKEY_CLASSES_ROOT\\$ext {}]
# Work out where to look for the command
set path HKEY_CLASSES_ROOT\\$type\\Shell\\Open\\command
# Read the command!
set command [registry get $path {}]
puts "$ext opens with $command"
I would write (for Tcl 8.5)
exec {*}[auto_execok start] "" $filename
(discussion here). That may display a cmd window though.
If you have an earlier Tcl,
eval exec [auto_execok start] {""} [list $filename]
For the records: Using the Tcl extension TWAPI, one might also want to look at:
twapi::shell_execute -path $filename