Broken command line sent to .com file on drag and drop

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: white, Hacker, petermad, Stefan2

avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Broken command line sent to .com file on drag and drop

Post by *avada »

Hi!

With this button:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\plugins\mplayer\mpv.com
%P%N
%COMMANDER_PATH%\plugins\mplayer\mpv.exe

%COMMANDER_PATH%\plugins\mplayer\
0
-1
If I drag and drop a file a broken command line is executed. Apparently the path is not quoted so every time there's a space the program tries to open it as a file path.
If I just click on the button the selected file plays normally.

Maybe it's related to these old bugs: bug 1 bug2
Last edited by avada on 2016-07-28, 08:48 UTC, edited 1 time in total.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6449
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

Why don't you use %P%S
Which according to the help inserts the names of all selected files into the command line, with full path.
Names containing spaces will be surrounded by double quotes.
Do NOT put quotes around %P%S yourself!
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Post by *Dalai »

2avada
Can you be more specific about which path is not quoted correctly? There are at least four of them in your button, three of which are relevant for the command line of the executed process.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

%COMMANDER_PATH%\plugins\mplayer\mpv.com
Shouldn't that be: %COMMANDER_PATH%\plugins\mplayer\mpv.exe
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: Broken command line sent to .com file on drag and drop

Post by *nsp »

avada wrote:Hi!

With this button:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\plugins\mplayer\mpv.com
%P%N
%COMMANDER_PATH%\plugins\mplayer\mpv.exe

%COMMANDER_PATH%\plugins\mplayer\
0
-1
If I drag and drop a file a broken command line is executed. Apparently the path is not quoted so every time there's a space the program tries to open it as a file path.
If I just click on the button the selected file plays normally.

Maybe it's related to these old bugs: bug 1 bug2
I can not confirm this..

I use mpv same way as you from command line and did a test with drag and drop a file with space in full path/name using your button. (all was OK)
Can you check:
  • - your mpv profile if you have an mpv.conf
    - with a new mpv install
    - with the code supplied in your button
You do not need to use the console wrapper unless you need the terminal messages...
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Is it really mpv.com, or is this a typo? Please also answer the questions of the other forum users.
Author of Total Commander
https://www.ghisler.com
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

Dalai wrote:2avada
Can you be more specific about which path is not quoted correctly? There are at least four of them in your button, three of which are relevant for the command line of the executed process.

Regards
Dalai
What do you mean there's just the program path. And the file I want to open. Of course it's the path to the file I want to open is what broken.
Horst.Epp wrote:Why don't you use %P%S
Which according to the help inserts the names of all selected files into the command line, with full path.
Names containing spaces will be surrounded by double quotes.
Do NOT put quotes around %P%S yourself!
I'm familiar with %P%S, also it's likely irrelevant, because that parameter field doesn't seem to apply when I drop a file on the icon. And as a said it works when I click it.
petermad wrote:
%COMMANDER_PATH%\plugins\mplayer\mpv.com
Shouldn't that be: %COMMANDER_PATH%\plugins\mplayer\mpv.exe
Not if you want to see the CLI outpot of mpv.
ghisler(Author) wrote:Is it really mpv.com, or is this a typo? Please also answer the questions of the other forum users.
Yes it is. (The reasons I mentioned above)
I also use mpv.com as an external viewer in lister. There I had to use:

Code: Select all

"%COMMANDER_PATH%\plugins\mplayer\mpv.com" "%1"
For the same reason. That's what one of the threads I linked is about.

I would have answered before, but it's dependent on when I remember writing here, or happen to come here since the notifications don't work.
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

Horst.Epp wrote:Why don't you use %P%S
Which according to the help inserts the names of all selected files into the command line, with full path.
Names containing spaces will be surrounded by double quotes.
Do NOT put quotes around %P%S yourself!
I tried it and it makes no difference, as I expected.
But thanks for the tip anyway. It'll be very useful for other buttons.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Problem is: .com is 16-bit, so TC uses %p%n not %P%N when drag&drop, because 16-bit programs usually don't understand long names.
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

avada,
You can create MPV.BAT file in MPV dir and use it instead of COM file:

Code: Select all

@"%~dpn0.com" %*
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

ghisler(Author) wrote:Problem is: .com is 16-bit, so TC uses %p%n not %P%N when drag&drop, because 16-bit programs usually don't understand long names.
Well HolgerK said in response to you in one of the older threads:
HolgerK wrote:
ghisler(Author) wrote:.com programs are 16-bit only
Not necessary true.
http://stackoverflow.com/questions/2115651/difference-between-com-exe-and-bat wrote:However DOS and Windows eventually went to a model where the file extension in a .COM and .EXE didn't mean anything. The program loader first checks the first two bytes of the file. If it happens to be the string MZ (legend has it this stands for the initials of an early Microsoft employee), it will treat it as an EXE, otherwise it will load it as if it were a COM file. Since MZ doesn't map to a sensible x86 instruction to start a program, they can get away with this. Net effect: In some versions of DOS/Windows, an .EXE can be named with .COM and vice versa. For example, in many versions of DOS/Windows, the famous COMMAND.COM was actually an EXE.
Just try it. Rename a 64 bit notepad.exe to notepad.com. :wink:
I would not suggest to use the .com extension for modern executables, but in fact windows checks the header for "MZ" and uses the program loader strategy instead of simply mapping max 64kB into memory and execute the first instruction of the memory block.

Regards
Holger
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

ghisler(Author) wrote:Problem is: .com is 16-bit, so TC uses %p%n not %P%N when drag&drop, because 16-bit programs usually don't understand long names.
But what I see in the mpv output is that the long path is passed only without quotes because mpv shows every space divided segment as a filename not found. If actually short path would be passed than that would appear or would be actually played.

I don't know how this behavior can be defended when it's clearly wrong...
I get this for "d:\a folder\a file with spaces.mp4"

Image: https://abload.de/img/tc-path-buguss9d.png

(Also com is not necessarily 16 bit as others pointed out)

Do short names even exist under windows 8+?

And what if someone disabled 8.3 name creation? (It's possible in xp for a certainty)
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

Since 16-bit applications don't work in 64-bit Windows, TC shouldn't use %p%n for COM files in 64-bit Windows.
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

MVV wrote:avada,
You can create MPV.BAT file in MPV dir and use it instead of COM file:

Code: Select all

@"%~dpn0.com" %*
Thanks for the workaround. What does this actually do?
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

avada wrote:Thanks for the workaround. What does this actually do?
Well, %~dpn0 means full path to batch file w/o extension, so %~dpn0.com is a full path to COM file near the batch with same name. And %* means all arguments passed to batch file. So this batch simply starts COM file and passes all arguments to it.
Post Reply