button bar command quotes not right
Moderators: Hacker, petermad, Stefan2, white
button bar command quotes not right
using commands in button bar, is broken on long filename dirs..
when i use a batch file for command that's in a long filename dir, it doesn't work..[with %P%S for params]
to make it work correctly, i have to put a single double-quote in front of the command: "c:\path to\command.bat
and put closing double-quote in my params: " %P%S
so the command eventually gets to be "c:\path to\command.bat" %P%S when put back together...
otherwise, even echoing out the params with:
for %%1 in (%*) do echo %%1
doesn't work...
so something's knocking off the ending quote from command at top..
[ps i tried using no quotes and still not work when having long filename paths.
when i use a batch file for command that's in a long filename dir, it doesn't work..[with %P%S for params]
to make it work correctly, i have to put a single double-quote in front of the command: "c:\path to\command.bat
and put closing double-quote in my params: " %P%S
so the command eventually gets to be "c:\path to\command.bat" %P%S when put back together...
otherwise, even echoing out the params with:
for %%1 in (%*) do echo %%1
doesn't work...
so something's knocking off the ending quote from command at top..
[ps i tried using no quotes and still not work when having long filename paths.
Every parameter with spaces must be enclosed with quotes (a pair of quotes, one before and one after parameter, not just single quote). In your example:
1st parameter: "c:\path to\command.bat" - a pair of quotes;
2nd etc parameters: %P%S - TC quotes paths with spaces.
So I can't see any problem here.
1st parameter: "c:\path to\command.bat" - a pair of quotes;
2nd etc parameters: %P%S - TC quotes paths with spaces.
So I can't see any problem here.
ahh, but that's just it, if you put 2 quotes on command, it doesn't work..
it's only by putting one up top, and one in params does it work...
hence the bug...
i should be able to put a leading and trailing quote on the command, and none in params line, but it knocks off the trailing one on the command for some reason..so only option is to put it on params line to get it to work properly..
it's only by putting one up top, and one in params does it work...
hence the bug...
i should be able to put a leading and trailing quote on the command, and none in params line, but it knocks off the trailing one on the command for some reason..so only option is to put it on params line to get it to work properly..
broken in previous versions as well
i see it's broken in 7.50 as well... 
same behavior as mentioned before, 2 quotes on command that needs them don't work, the second quote gets stripped off for some reason..
as i said before, putting 2 quotes on command and none on params line doesn't work..
i have to add a quote on params line because the second one on command line gets chopped off at runtime..
cmd: "command
param: " %P%S
works..
cmd: "command"
param: %P%S
doesn't..

same behavior as mentioned before, 2 quotes on command that needs them don't work, the second quote gets stripped off for some reason..
as i said before, putting 2 quotes on command and none on params line doesn't work..
i have to add a quote on params line because the second one on command line gets chopped off at runtime..
cmd: "command
param: " %P%S
works..
cmd: "command"
param: %P%S
doesn't..

A-h, I understood reason of your problem. I forget about it last time. Batch files are executed by cmd.exe which works in stupid way in XP:
It requires additional pair of quotes around command and parameters, and it cuts ending quote if first command symbol is quote.
Anyway it is not a TC problem, TC simply tells Windows to execute batch file, and system starts cmd.exe with corrsesponding parameters.
So I recommend to use direct command if you need to start batch file:
Don't forget last quote, cmd.exe will cut it from last quoted parameter otherwise.
Code: Select all
cmd.exe /c "command parameters"
Code: Select all
cmd.exe /c ""c:\path to\command.bat" "1.txt" "2.txt" "3.txt""
Anyway it is not a TC problem, TC simply tells Windows to execute batch file, and system starts cmd.exe with corrsesponding parameters.
So I recommend to use direct command if you need to start batch file:
Code: Select all
Command: cmd.exe /c ""c:\path to\command.bat"
Parameters: %P%S "
so it looks as if the problem is the quotes around the "command parameters"...who puts those in? they aren't needed at all..
each command/param will have it's own quotes if needed so that extra set surrounding it all is completely unnecessary..
cmd.exe doesn't require it..
try running cmd.exe /c "some command" param1 param2
or cmd.exe /c command param1 param2
no problem..
so wherever the 'extra' set of quotes are coming from is messing the whole thing up..
so why does my workaround of putting second quote on second line work?
the second quote isn't getting 'removed', it's made obsolete by closing itself before the data it's supposed to be quoting:
cmd.exe /c ""c:\path to\command.bat" "1.txt" "2.txt" "3.txt""
equals
cmd.exe /c empty quoted string-"", unquoted path-c:\path to\command.bat, another empty quote-" ", unquoted-1.txt,empty quote-" ",etc,etc...
see what i'm saying?
the extra surrounding quotes make all starting quotes into ending quotes, and vice-versa..
each command/param will have it's own quotes if needed so that extra set surrounding it all is completely unnecessary..
cmd.exe doesn't require it..
try running cmd.exe /c "some command" param1 param2
or cmd.exe /c command param1 param2
no problem..
so wherever the 'extra' set of quotes are coming from is messing the whole thing up..
so why does my workaround of putting second quote on second line work?
the second quote isn't getting 'removed', it's made obsolete by closing itself before the data it's supposed to be quoting:
cmd.exe /c ""c:\path to\command.bat" "1.txt" "2.txt" "3.txt""
equals
cmd.exe /c empty quoted string-"", unquoted path-c:\path to\command.bat, another empty quote-" ", unquoted-1.txt,empty quote-" ",etc,etc...
see what i'm saying?
the extra surrounding quotes make all starting quotes into ending quotes, and vice-versa..
Yes, they aren't needed for human. But it is Microsoft...
Try to open command line and execute following command:
It works fine.
And then try to remove first and last quotes...
It doesn't work! It says that it can't find a file "c:\path". As I said, it removes first and last characters if they are both quotes (and does nothing if not).
You can check command line that you get by your way (from 1st post), it produces following one:
I don't know why it works but it works. Stupid cmd.exe's logic (or maybe OS just cuts spaces at the end of filename when cmd opens the file).
Try to open command line and execute following command:
Code: Select all
cmd.exe /c ""c:\path to\command.bat" "1.txt" "2.txt" "3.txt""
And then try to remove first and last quotes...
Code: Select all
cmd.exe /c "c:\path to\command.bat" "1.txt" "2.txt" "3.txt"
You can check command line that you get by your way (from 1st post), it produces following one:
Code: Select all
cmd /c ""c:\path to\command.bat " C:\1.txt"
ahh,i see now...only with quotes on params does it mess up...
why using cmd /c?
shellexecutes don't have this problem..[at least i think..lol]
it's just that this is confusing to the user, going against conventional standards and logic..but i understand now it's win's fault..still..
sorry to take up your time on this but it seems a messy way for this otherwise perfect program to have to deal with this simple problem that's apparently been around for ages..
does this not affect regular executables? [.exe]
why using cmd /c?
shellexecutes don't have this problem..[at least i think..lol]
it's just that this is confusing to the user, going against conventional standards and logic..but i understand now it's win's fault..still..
sorry to take up your time on this but it seems a messy way for this otherwise perfect program to have to deal with this simple problem that's apparently been around for ages..
does this not affect regular executables? [.exe]