Starting firefox in C:\Program Files instead of...

English support forum

Moderators: Hacker, petermad, Stefan2, white

User avatar
HolgerK
Power Member
Power Member
Posts: 5411
Joined: 2006-01-26, 22:15 UTC
Location: Europe, Aachen

Post by *HolgerK »

Sorry, I don' want to participate in a flame war between Explorer an TC.
And please don't mix up the Explorer GUI and shell API's like ShellExecute.

I did not installed a firefox beta, but a simple test reveals a different behavior inside TC:

1) Copy (only) "firefox.exe" into a different temporary directory
2) start this "firefox.exe" using different methods:
a) from command line
b) using the context menu, a button or a simple double click.

In case of a) the installed version of FireFox is started (this is the behavior you complain about. And I agree: "This is not expected" :!: )

Using method b) a dialog pops up:

Code: Select all

---------------------------
XULRunner
---------------------------
Couldn't read application.ini
---------------------------
OK   
---------------------------
Expected behavior, because the (incomplete) copied "firefox.exe" was started, and not the "firefox.exe" found via "App paths\firefox.exe" :!:

I guess if you start the beta1 "firefox.exe" via context menu everything is okay for you.

So the simple question is:

Why is there a difference inside TC, when starting an application via command line, compared to other calling methods available in TC :?:

Regards,
Holger
User avatar
petermad
Power Member
Power Member
Posts: 16113
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

2Hacker
Hm, try this experiment:
Left: c:\Left
Right: c:\Right <- active panel

Inside the right panel, enter Subdir:
Left: c:\Left
Right: c:\Right\Subdir <- active panel

Press Tab:
Left: c:\Left <- active panel
Right: c:\Right\Subdir

Now go to Configuration - Options - Plugins - File system plugins - Configure - Add.
Here the dialog opens with C:\Right\Subdir instead of c:\Left.
That's special for adding plugins (and other TC configurations) - here TC always go to the last directory you have navigated into no matter what panel you are in.

If you do your experiment but instead (when in the left panel) type for example cmd /k in the command line you will see that TC puts you in c:\left and if you do the same in the right panel TC puts you in c:\right\subdir
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

petermad,
It seems you are right, the working dir seems to be set before executing commands from the command line.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
petermad
Power Member
Power Member
Posts: 16113
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

the working dir seems to be set before executing commands from the command line.
Not only from the command line, also from the Button bar and the Start menu (unless the Start path is set specifically).
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
Hacker
Moderator
Moderator
Posts: 13144
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

petermad,
Well, OK, but only the command line is relevant for this thread.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
avada
Senior Member
Senior Member
Posts: 217
Joined: 2007-10-05, 06:24 UTC

Post by *avada »

I think this is a flaw, and should be fixed. It can be very misleading. I and I think most other people assume that if I type the name of an exe in the command line TC starts the one in that directory (like in CMD), but it doesn't always.
Windows 10
User avatar
karlchen
Power Member
Power Member
Posts: 4605
Joined: 2003-02-06, 22:23 UTC
Location: Germany

Post by *karlchen »

Hello, Christian.

As this thread, Problem with launching programs from current directory, which is about the same problem that this two year old thread is about, suggests that the Total Commander behaviour has never been corrected.

The flaw inside T.C. has been explained by HolgerK
+ how it should be
+ what TC really does

To the best of my knowledge, there has never been a statement why TC should not follow the correct order (how it should be).
Has this slipped your attention?
Or is this going to be corrected soon?

Kind regards,
Karl
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50860
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Sorry but I don't understand the problem. Do you mean that the command line should not launch programs from the current directory?
Author of Total Commander
https://www.ghisler.com
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

ghisler(Author) wrote:Sorry but I don't understand the problem. Do you mean that the command line should not launch programs from the current directory?
Suppose that you have some program MyProgram.exe that is installed and registered in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MyProgram.exe key (its full path is set as default value of the key). And suppose you have in current directory some program called MyProgram.exe (same name but it is another program or its version). Now you want to start program that is in current directory. You type MyProgram in command line (or press Ctrl+Enter), then maybe you write some parameters... and finally you press Enter. And Total Commander starts program that registered in App Paths key instead of program that is in current directory!!!! It is expected that program name will is searched in current directory at first, and only if it is not found there it is searched in other places.
User avatar
petermad
Power Member
Power Member
Posts: 16113
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

It is expected that program name is searched in current directory at first, and only if it is not found there it is searched in other places.
I totally agree - that's how it should be.

But next question is, if a program is in the environment path and a program with the same name is registered in HKEY_LOCAL_MACHINE\.... but with another path - which of those two should take preceedence?
License #524 (1994)
Danish Total Commander Translator
TC 11.55rc4 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1393a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

petermad wrote:But next question is, if a program is in the environment path and a program with the same name is registered in HKEY_LOCAL_MACHINE\.... but with another path - which of those two should take preceedence?
I think we should leave this moment as is - App Paths before environment paths. TC uses such approach for many years so this logic will be kept. So,
1. Look for executable in current directory,
2. Look for executable in App Paths,
3. Look for executable in PATH.


BTW I think I found bug reason. ShellExecute function works in this strange way - even if executable exists in current directory it launches executable that is registered in App Paths. So we need to add just a check: if executable exists in current directory, start it, else call ShellExecute and let it find and start program. We may just append current path to executable name and use ShellExecute then - all other function parameters will be the same. E.g. something like this:

Code: Select all

if (Pos('\', ApplicationPath) = 0 and GetFileAttributes(ApplicationPath) <> INVALID_FILE_ATTRIBUTES) then ApplicationPath := '.\' + ApplicationPath;
ShellExecute(...); // or ShellExecuteEx(...)
(as I see, we can use just '.\' as current path here - and it works perfectly if file exists in current directory)

BTW2, I've never noticed this strange ShellExecute behaviour before - maybe because I usually start via command line programs that are not registered in App Paths.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50860
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Maybe this was done for security reasons ("application planting")?
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 »

Maybe TC could add ".\" before the filename that was added via ctrl+enter. That would prevent most of the confusion.
Windows 10
User avatar
MVV
Power Member
Power Member
Posts: 8711
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

ghisler(Author) wrote:Maybe this was done for security reasons ("application planting")?
I think they just didn't think about it. Anyway if I have EXE in current directory, I expect that it will be started. But maybe you may add an option for security reasons.
Post Reply