-Cannot delete folder after open configuration files
Moderators: Hacker, petermad, Stefan2, white
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
This is NOT a bug: Windows refuses to delete a directory which is the current directory in ANY open program. So when you launch a program from a directory and that program doesn't change the current directory, you will not be able to delete that directory until you close that program.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Let's make a small summary.
1) This is of course not a bug, that Windows doesn't allow to delete a directory that is being used by some application (Notepad in this case).
2) TC could be improved in an easy way - when launching Notepad with INI files, TC should set working directory of this Notepad to the directory of these INI files, not to the directory that the user can see in the active TC panel when Configuration -> Change Settings Files Directly command was used. In this way, Notepad will not block user actions by keeping handle to the directory that is shown in the active TC panel. This may be considered as a small TC bug, which can be fixed in 1 minute.
Regards
1) This is of course not a bug, that Windows doesn't allow to delete a directory that is being used by some application (Notepad in this case).
2) TC could be improved in an easy way - when launching Notepad with INI files, TC should set working directory of this Notepad to the directory of these INI files, not to the directory that the user can see in the active TC panel when Configuration -> Change Settings Files Directly command was used. In this way, Notepad will not block user actions by keeping handle to the directory that is shown in the active TC panel. This may be considered as a small TC bug, which can be fixed in 1 minute.
Regards
I agree that it would be user friendly if TC did set the working directory to %COMMANDER_INI%\.. when launching cm_ConfigChangeIniFiles
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
I still disagree. The bug is, that notepad is inproperly called.ghisler(Author) wrote:This is NOT a bug
BTW, if you happen to execute the "edit configuration files" menu item while an USB drive directory is current, that drive cannot be safely removed as long as the files are kept open. There's no reason to not fix such behaviour. Also, for the user it is not really obvious what he or she has to do to remove the device.
- ghisler(Author)
- Site Admin
- Posts: 50541
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
No, it's not improperly called! Many programs use the current directory when searching for files, so it's beneficial to call them with the current directory.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
Not that I care about this one, but you realize this discussion is *only* about one specific case when you click Configuration->Change Settings Files Directly, right? So there's no unknown program which might need something in *current* directory. There's only predictable notepad.exe and the only directory it needs, is the one where TC's ini files are located.
I agree with ghisler(Author) that TC should use the current directory when launching any programs in normal cases.
The idea of TC is that the user works with files and folders in the TC panels. So when he goes to - let's say - C:\Documents and Settings\X\My Documents\, he may launch Notepad/Word/etc. with this folder as the current directory and benefit from easy access to other files inside this directory in the launched application.
In the specific case of editing INI files, current TC behavior invalidates this idea, because the user loses full control of folders shown in panels (he can't delete the folder that was shown in the active panel at the moment of using the Configuration -> Change Settings Files Directly command).
There are two possibilities:
1) Current TC behavior - when loading INI file(s) to the Notepad(s), TC locks the folder shown in the active panel.
Advantage: The user can easily open other files from that folder in Notepad by using Notepad's File -> Open command - but is this really needed? It's much easier for the TC user to find the required file in the active TC panel and press F4.
Disadvantage: The user can't delete that folder.
2) When loading INI file(s) to the Notepad(s), TC locks the folder containing these INI files, not the folder in the active panel.
Advantage: The user retains full control over the folder displayed in the active panel.
Disadvantage: Is there any? The user has exactly what he wants - INI file(s) loaded into Notepad(s). Most probably he will not need to open any other files in this/these Notepad(s) instance(s).
So, in my personal opinion, this second case would be better in this specific case of editing INI files.
Regards
The idea of TC is that the user works with files and folders in the TC panels. So when he goes to - let's say - C:\Documents and Settings\X\My Documents\, he may launch Notepad/Word/etc. with this folder as the current directory and benefit from easy access to other files inside this directory in the launched application.
In the specific case of editing INI files, current TC behavior invalidates this idea, because the user loses full control of folders shown in panels (he can't delete the folder that was shown in the active panel at the moment of using the Configuration -> Change Settings Files Directly command).
There are two possibilities:
1) Current TC behavior - when loading INI file(s) to the Notepad(s), TC locks the folder shown in the active panel.
Advantage: The user can easily open other files from that folder in Notepad by using Notepad's File -> Open command - but is this really needed? It's much easier for the TC user to find the required file in the active TC panel and press F4.
Disadvantage: The user can't delete that folder.
2) When loading INI file(s) to the Notepad(s), TC locks the folder containing these INI files, not the folder in the active panel.
Advantage: The user retains full control over the folder displayed in the active panel.
Disadvantage: Is there any? The user has exactly what he wants - INI file(s) loaded into Notepad(s). Most probably he will not need to open any other files in this/these Notepad(s) instance(s).
So, in my personal opinion, this second case would be better in this specific case of editing INI files.
Regards
Unfortunately there are a lot of similar problems with any folder. E.g. it may be CMD.exe, it may be some program that you start via file context menu, it may be some other program like text editor etc. And simplest way to delete such locked folder is to close all its open handles (by closing programs or by changing dirs in them if they allow it or by closing handles forcedly).
In case of such special function TC always opens specific files (configuration files) so personally I agree that TC should set proper working directory (one containing these files). It won't solve other problems with locked dirs though.
However this may be easilly solved with custom user command opening configuration files, e.g.:
Such command may be made as a buttonbar button, or as a user-command (in such case it may be added to main menu, even instead of standard command opening cfg files; also hotkey may be assigned to it). Also your favorite text editor may be called instead of unhandy Notepad.
In case of such special function TC always opens specific files (configuration files) so personally I agree that TC should set proper working directory (one containing these files). It won't solve other problems with locked dirs though.
However this may be easilly solved with custom user command opening configuration files, e.g.:
Code: Select all
Command: cmd.exe
Parameters: /c "start "" "notepad.exe" %%COMMANDER_INI%% & start "" "notepad.exe" %%COMMANDER_INI%%\..\wcx_ftp.ini"
Start path: C:\Windows (this is a key setting that solves this problem)
Minimized: yes
The only problem with this is if the user are using another filename for wcx_ftp.iniCommand: cmd.exe
Parameters: /c "start "" "notepad.exe" %%COMMANDER_INI%% & start "" "notepad.exe" %%COMMANDER_INI%%\..\wcx_ftp.ini"
Start path: C:\Windows (this is a key setting that solves this problem)
Minimized: yes
We could use an environment variable for wcx_ftp.ini too.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Thanks, MarcinW, for this summary.
What really makes this a problem to the user, is that, although there's a message shown about the folder or drive being locked, those config files are not related to the folder or drive, so it's not obvious which process is responsible.
Furthermore, the user cannot safely remove an external (USB) drive, if the active folder at the moment of opening config files had been opened accidentally from that drive.MarcinW wrote:1) Current TC behavior - when loading INI file(s) to the Notepad(s), TC locks the folder shown in the active panel.
Advantage: The user can easily open other files from that folder in Notepad by using Notepad's File -> Open command - but is this really needed? It's much easier for the TC user to find the required file in the active TC panel and press F4.
Disadvantage: The user can't delete that folder.
What really makes this a problem to the user, is that, although there's a message shown about the folder or drive being locked, those config files are not related to the folder or drive, so it's not obvious which process is responsible.
There is probably about 300 000 users of TC, so if 1% of them has this problem, it gives 3 thousands of users...Horst.Epp wrote:most users never have such a problem.
BTW, according to side effects, the current discussion shows, that there are rather no practical side effects of such potential change.
And this is true, that we are currently unable to dismount USB drive safely, if it has been shown in the active panel during launching the "Change Settings Files Directly" command.
Regards