bar button doesn't start program

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

bar button doesn't start program

Post by *sgp »

This button fails starting the program with TC6.55 and TC7b3. When the button is first defined, sometimes it works but then it doesn't anymore. It never works if I close then restart TC. I think it depends on the maximum length of the Parameters after %P %N etc are expanded. Can this limit be increased in the next build?

Code: Select all

Command: V:\bin\PowerPro\pp0.exe
Parameters: .tc@bar2menu(?'%%COMMANDER_PATH%%\cmd\CMD.BAR',?'-P %P -N %N -L %L -T %T')
User avatar
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Re: bar button doesn't start program

Post by *karlchen »

sgp wrote:I think it depends on the maximum length of the Parameters after %P %N etc are expanded. Can this limit be increased in the next build?
Whatever Christian does his programme will not be able to launch a commandline if its length exceeds the limit defined by Windows (version dependant). :idea:

Karl
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Command line lenght limit in CreateProcess is system independent (as long as it's win32 ;) ) and is c.a. 32K characters.
User avatar
karlchen
Power Member
Power Member
Posts: 4603
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hi, m^2.

Thanks for clarifying the CreateProcess limit.

Yet, it may not be as simple as that, depending on what T.C. does internally.

Also cf here, please: What is the command line length limit?.

So in the end the effective limit may be much lower than the 32K allowed by the WinAPI function CreateProcess().

So, in order to determine if T.C. is the limitting factor, we will need to know how T.C. processes the button bar command line plus its parameter line. (Christian?)

Oh, yes, and the launched programme may not be able to process a very long commandline - whatever its developer defined as "very long".

Ciao,
Karl
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

Tested.
My program starts, but it's command line is cut to c.a. 259 characters. (ADDED: Exactly 259 characters.) Maybe PowerPro refuses to start with incorrect command line?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Indeed the command line is currently limited to 259 characters. Win2k supports up to 2k, WinXP up to 8k. I will try to support a longer command line.
Author of Total Commander
https://www.ghisler.com
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

m^2 wrote:Tested.
My program starts, but it's command line is cut to c.a. 259 characters. (ADDED: Exactly 259 characters.) Maybe PowerPro refuses to start with incorrect command line?
Thank you for finding the exact limit. Your program starts but I think it's just unpredictable, here the same program and same command line some times starts and some times doesn't - checked with process explorer.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

ghisler(Author) wrote:I will try to support a longer command line.
Thank you
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Please retry now, beta 4 supports a longer command line internally.
Author of Total Commander
https://www.ghisler.com
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

ghisler(Author) wrote:Please retry now, beta 4 supports a longer command line internally.
I really think that there's a bug somewhere in this interface. It behaves inconsistently. For instance, if I start tc7pb4 and immediately run my command, previously defined as:

Code: Select all

Command: V:\bin\PowerPro\pp0.exe 
Parameters: .tc@bar2menu(?"%COMMANDER_PATH%\cmd\CMD.BAR",?"-P %P -N %N -L %L -T %T")
The -P %P... stuff doesn't get expanded (COMMANDER_PATH does and it's predefined in my environment). So I change it to

Code: Select all

Command: cmd.exe /k echo .tc@bar2menu(?"%COMMANDER_PATH%\cmd\CMD.BAR",?"-P %P -N %N -L %L -T %T")
Parameters: -P %P -N %N -L %L -T %T
and this time the parameters part gets expanded but not the -P %P... in the commands part, so I change everything to:

Code: Select all

Command: V:\bin\PowerPro\pp0.exe .tc@bar2menu(?"%COMMANDER_PATH%\cmd\CMD.BAR"
Parameters: ,?"-P %P -N %N -L %L -T %T") 
and this time everything gets correctly expanded... but then I close TC, restart it press the command button again and the parameters part isn't passed on to the command-line anymore !!

This is on Windows XP Pro SP2.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48079
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I think that you got it the wrong way. Because of the ambiguity, environment variables only get expanded in the "command" part, while parameters like %P are only expanded in the "parameters" part. Can't you confirm that?
Author of Total Commander
https://www.ghisler.com
User avatar
m^2
Power Member
Power Member
Posts: 1413
Joined: 2006-07-12, 10:02 UTC
Location: Poland
Contact:

Post by *m^2 »

I can.
%COMMANDER_PATH% in the parameters field is treated as %C OMMANDER_PATH %
So when I have a button with %COMMANDER_PATH% parameters field and nothing %C would expand to, I get OMMANDER_PATH parameter.
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

ghisler(Author) wrote:environment variables only get expanded in the "command" part, while parameters like %P are only expanded in the "parameters" part. Can't you confirm that?
I can confirm that. But the outstanding problem is
sgp wrote:

Code: Select all

Command: V:\bin\PowerPro\pp0.exe .tc@bar2menu(?"%COMMANDER_PATH%\cmd\CMD.BAR" 
Parameters: ,?"-P %P -N %N -L %L -T %T")
and this time everything gets correctly expanded... but then I close TC, restart it press the command button again and the parameters part isn't passed on to the command-line anymore !!
In fact I just did it, and this time I got an application error from pp0.exe saying that the command line is incomplete, that is the parameters line either didn't get passed to the API that started pp0.exe, or it got mongled by the API that started pp0.exe.
User avatar
ND
Member
Member
Posts: 150
Joined: 2006-04-10, 16:24 UTC
Location: Sibiu, RO

Post by *ND »

At some point I had a similar problems, and my conclusion was: always remember to enclose the "%parameters" in quotes.

I did some tests with a button configuration like sgp's, and here's what I found:


When pressing the button while the cursor is on a file or directory...

Code: Select all

"D:\PP Sym\pp0.cmd" .tc@bar2menu(?"F:\totalcmd\cmd\CMD.BAR" ?"-P F:\ -N "long file name . ext" -L C:\DOCUME~1\ND\LOCALS~1\Temp\CMD9E.tmp -T F:\long dir name\")
Note that the file name "long file name . ext" (source tab) is enclosed in quotes, but the directories "F:\" (source tab) and "F:\long dir name\" (target tab) are not, so that might cause some of sgp's problems.


When pressing the button while the cursor is on the "parent dir" [..] marker...

Code: Select all

"D:\PP Sym\pp0.cmd" .tc@bar2menu(?"F:\totalcmd\cmd\CMD.BAR"
Here the %parameters are not passed to the command line anymore.
aNDreas Bolotă
The truth always carries the ambiguity of the words used to express it. (Frank Herbert, God Emperor of Dune)
sgp
Senior Member
Senior Member
Posts: 355
Joined: 2005-01-31, 16:04 UTC

Post by *sgp »

ND wrote:When pressing the button while the cursor is on the "parent dir" [..] marker...
... the %parameters are not passed to the command line anymore.
That's it! Thank you ND, you figured out the remaining cause of my problem. When the cursor is on the [..] marker TC doesn't pass the "parameters" part of the button. I think this is a design limitation that should be removed. I don't see why TC should pass "parameters" when a file is selected and not pass "parameters" when [..] is selected. Look at my case, "parameters" includes syntax characters that are always needed regardless of which target file/[..] is selected.
Post Reply