• something wrong with special char in "exec exploer.exe" command

    From meshparts@[email protected] to comp.lang.tcl on Mon Oct 19 21:39:13 2026
    From Newsgroup: comp.lang.tcl

    I'm using in Tcl with Windows

    exec explorer.exe /e, "[file nativename $path]" &

    to open files with the OS default program.

    Now I have an issue with a text file path that contains "=" in the file
    name, e.g. t=4.out

    The issue seems to be explorer.exe which does not like the "=" sign.
    If I execute the command in cmd.exe and use double quotes, then the
    command works:

    explorer.exe /e, "t=4.out" &

    But executed from Tcl, it does not:

    exec explorer.exe /e, "t=4.out" &

    The result is, that the given file is not found and a generig Explorer
    window is opened instead of the file in my default text editor.

    I tried to force the double quotes by using \" and so on, but nothing
    worked.

    Any ideas?

    Thanks
    Alex


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Obermeier@[email protected] to comp.lang.tcl on Mon Oct 19 23:11:12 2026
    From Newsgroup: comp.lang.tcl

    I noticed the same problem in my poApps program using files with "=" in the file name.

    Previously I had the following command to open a file with the associated command on Windows:
    exec cmd /c "t=4.txt" &
    which did not work.

    Changing the above command to
    exec cmd /c start "t=4.txt" &
    works with files using "=" in the name.

    Paul

    Am 19.10.2026 um 21:39 schrieb meshparts:
    I'm using in Tcl with Windows

    exec explorer.exe /e, "[file nativename $path]" &

    to open files with the OS default program.

    Now I have an issue with a text file path that contains "=" in the file name, e.g. t=4.out

    The issue seems to be explorer.exe which does not like the "=" sign.
    If I execute the command in cmd.exe and use double quotes, then the command works:

    explorer.exe /e, "t=4.out" &

    But executed from Tcl, it does not:

    exec explorer.exe /e, "t=4.out" &

    The result is, that the given file is not found and a generig Explorer window is opened instead of the file in my default text editor.

    I tried to force the double quotes by using \" and so on, but nothing worked.

    Any ideas?

    Thanks
    Alex



    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Luis Alejandro Muzzachiodi@[email protected] to comp.lang.tcl on Mon Oct 19 19:05:21 2026
    From Newsgroup: comp.lang.tcl

    El 19/10/2026 a las 16:39, meshparts escribió:
    I'm using in Tcl with Windows

    exec explorer.exe /e, "[file nativename $path]" &

    to open files with the OS default program.

    Now I have an issue with a text file path that contains "=" in the file name, e.g. t=4.out

    The issue seems to be explorer.exe which does not like the "=" sign.
    If I execute the command in cmd.exe and use double quotes, then the
    command works:

    explorer.exe /e, "t=4.out" &

    But executed from Tcl, it does not:

    exec explorer.exe /e, "t=4.out" &

    The result is, that the given file is not found and a generig Explorer window is opened instead of the file in my default text editor.

    I tried to force the double quotes by using \" and so on, but nothing worked.

    Any ideas?

    Thanks
    Alex



    Hello,

    may be with twapi ?
    For example,

    package require twapi
    ::twapi::shell_execute -path "c:\\temp\\a=b.tcl"

    Alejandro


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From meshparts@[email protected] to comp.lang.tcl on Tue Oct 20 08:32:55 2026
    From Newsgroup: comp.lang.tcl

    Am 20.10.2026 um 00:05 schrieb Luis Alejandro Muzzachiodi:
    Hello,

    may be with twapi ?
    For example,

    package require twapi
    ::twapi::shell_execute -path "c:\\temp\\a=b.tcl"

    Alejandro

    Thank you Paul and Alejandro for the solutions.
    Both work with this file.
    What I wonder: Which one is best compatible with all sort of files?
    I remember in the past having problems with this and landing at
    explorer.exe. I don't remember which issues dough...
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From et99@[email protected] to comp.lang.tcl on Mon Oct 19 23:36:02 2026
    From Newsgroup: comp.lang.tcl

    Hi:

    In cmd.exe, = (like , and ;) acts as an argument delimiter, the same as a space, unless it is inside double quotes. So an unquoted t=4.out can be split into t and 4.out. Tcl's exec only quotes arguments containing whitespace, a double quote, or one of & | ^ < > ! ( ). The = sign isn't on that list, so t=4.out reaches the command line unquoted and gets mangled, and the quotes in your script are eaten by Tcl's parser.

    Skip explorer and use start with an empty title:

    exec cmd /c start "" [file nativename $path] &

    The "" matters: start treats its first argument, if quoted as the window title, so without it a quoted path (for example one with spaces) can be taken as the title instead of the file. Tcl passes the empty argument through as "", so start gets a real (empty) title and opens the path with the default program.

    -e

    On 10/19/2026 12:39 PM, meshparts wrote:
    I'm using in Tcl with Windows

    exec explorer.exe /e, "[file nativename $path]" &

    to open files with the OS default program.

    Now I have an issue with a text file path that contains "=" in the file name, e.g. t=4.out

    The issue seems to be explorer.exe which does not like the "=" sign.
    If I execute the command in cmd.exe and use double quotes, then the command works:

    explorer.exe /e, "t=4.out" &

    But executed from Tcl, it does not:

    exec explorer.exe /e, "t=4.out" &

    The result is, that the given file is not found and a generig Explorer window is opened instead of the file in my default text editor.

    I tried to force the double quotes by using \" and so on, but nothing worked.

    Any ideas?

    Thanks
    Alex



    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From meshparts@[email protected] to comp.lang.tcl on Tue Oct 20 08:52:35 2026
    From Newsgroup: comp.lang.tcl

    Am 20.10.2026 um 08:36 schrieb et99:
    Hi:

    In cmd.exe, = (like , and ;) acts as an argument delimiter, the same as
    a space, unless it is inside double quotes. So an unquoted t=4.out can
    be split into t and 4.out. Tcl's exec only quotes arguments containing whitespace, a double quote, or one of & | ^ < > ! ( ). The = sign isn't
    on that list, so t=4.out reaches the command line unquoted and gets
    mangled, and the quotes in your script are eaten by Tcl's parser.

    Skip explorer and use start with an empty title:

    exec cmd /c start "" [file nativename $path] &

    The "" matters: start treats its first argument, if quoted as the window title, so without it a quoted path (for example one with spaces) can be taken as the title instead of the file. Tcl passes the empty argument through as "", so start gets a real (empty) title and opens the path
    with the default program.

    -e

    Thank you! This is very important thing to know.
    So now I have the cmd and the twapi methods that seems to work fine.
    Still, which one should I use?
    Are there any other hidden traps that will crash either one?
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From greg@[email protected] to comp.lang.tcl on Tue Oct 20 16:11:50 2026
    From Newsgroup: comp.lang.tcl

    Am 19.10.26 um 21:39 schrieb meshparts:
    I'm using in Tcl with Windows

    exec explorer.exe /e, "[file nativename $path]" &

    to open files with the OS default program.

    Now I have an issue with a text file path that contains "=" in the file name, e.g. t=4.out

    The issue seems to be explorer.exe which does not like the "=" sign.
    If I execute the command in cmd.exe and use double quotes, then the
    command works:

    explorer.exe /e, "t=4.out" &

    But executed from Tcl, it does not:

    exec explorer.exe /e, "t=4.out" &

    The result is, that the given file is not found and a generig Explorer window is opened instead of the file in my default text editor.

    I tried to force the double quotes by using \" and so on, but nothing worked.

    Any ideas?

    Thanks
    Alex




    Hello,

    explorer and =

    https://www.geoffchappell.com/studies/windows/shell/explorer/cmdline.htm





    #with auto_execok

    exec {*}[auto_execok start] "" file nativename $path &


    Gregor
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Luis Alejandro Muzzachiodi@[email protected] to comp.lang.tcl on Tue Oct 20 18:26:37 2026
    From Newsgroup: comp.lang.tcl

    El 20/10/2026 a las 3:52, meshparts escribió:
    Am 20.10.2026 um 08:36 schrieb et99:
    Hi:

    In cmd.exe, = (like , and ;) acts as an argument delimiter, the same
    as a space, unless it is inside double quotes. So an unquoted t=4.out
    can be split into t and 4.out. Tcl's exec only quotes arguments
    containing whitespace, a double quote, or one of & | ^ < > ! ( ). The
    = sign isn't on that list, so t=4.out reaches the command line
    unquoted and gets mangled, and the quotes in your script are eaten by
    Tcl's parser.

    Skip explorer and use start with an empty title:

    exec cmd /c start "" [file nativename $path] &

    The "" matters: start treats its first argument, if quoted as the
    window title, so without it a quoted path (for example one with
    spaces) can be taken as the title instead of the file. Tcl passes the
    empty argument through as "", so start gets a real (empty) title and
    opens the path with the default program.

    -e

    Thank you! This is very important thing to know.
    So now I have the cmd and the twapi methods that seems to work fine.
    Still, which one should I use?
    Are there any other hidden traps that will crash either one?

    I guess the person who could best answer this is the author of twapi
    (Ashok P. Nadkarni).
    In any case, something to keep in mind:

    «The START command uses the same underlying Windows Shell API
    (ShellExecute) that explorer.exe uses when you double-click a file. It
    looks at the file's extension, checks the registry for the associated "FileType" (managed by the assoc command), and then looks up the command associated with that FileType (managed by the ftype command) to launch
    the correct program. This ensures your script respects the user's
    personal application choices.» (Credit : https://tutorialreference.com/batch-scripting/examples/faq/batch-script-how-to-open-a-file-with-its-default-program)

    Alejandro
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From meshparts@[email protected] to comp.lang.tcl on Wed Oct 21 08:24:06 2026
    From Newsgroup: comp.lang.tcl

    Am 20.10.2026 um 23:26 schrieb Luis Alejandro Muzzachiodi:
    I guess the person who could best answer this is the author of twapi
    (Ashok P. Nadkarni).
    In any case, something to keep in mind:

    «The START command uses the same underlying Windows Shell API (ShellExecute) that explorer.exe uses when you double-click a file. It
    looks at the file's extension, checks the registry for the associated "FileType" (managed by the assoc command), and then looks up the command associated with that FileType (managed by the ftype command) to launch
    the correct program. This ensures your script respects the user's
    personal application choices.» (Credit : https://tutorialreference.com/batch-scripting/examples/faq/batch-script- how-to-open-a-file-with-its-default-program)

    Alejandro

    Thanks. Looks like the two methods would be equivalent.
    I made my choice by counting the number of usages of each method in my application.
    twapi won, so I'll use it.
    --- Synchronet 3.22a-Linux NewsLink 1.2