Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001771Double CommanderFile operationspublic2017-03-16 17:152017-03-17 20:05
Assigned ToAlexx2000 
Platformx86-64OSWindowsOS VersionWindows 10
Product Version0.7.8Product Build 
Target Version0.8.0Fixed in Version0.8.0 
Summary0001771: Context menu commands run with wrong current directory
DescriptionWhen a context menu command (defined in HKEY_CLASSES_ROOT -> Folder -> shell -> (command name) -> command) is executed in Windows Explorer by right-clicking the background or a subdirectrory, it is executed with current working directory set to the directory you are currently browsing.

In DC, it works as expected when right-clicking the background, but if right-clicking a subdirectory and running a command it is instead always run with current directory set to the DC executable's directory.
Steps To ReproduceRight-click a file or subdirectory and execute an action in the Windows context menu. It will get run with current working directory set to the Double Commander executable's path.
Additional InformationI dug around in the code a bit and found out what's causing it.

In TShellContextMenu.PopUp, it's only setting the TCMINVOKECOMMANDINFO's lpDirectory if FBackground is true - and FBackground is only true if the user clicks the background rather than a subdirectory. So if a subdirectory is right-clicked, any commands are executed with lpDirectory unset, resulting in the current directory defaulting to Double Commander's installation path.

if FBackground then begin
  lpDirectory := PAnsiChar(CeUtf8ToSys(FFiles[0].FullPath));

I don't know the reasoning behind doing this, but to me this behavior seems incorrect.
It seems to me like the desirable behavior should be to do the same thing Windows Explorer does, and execute the command with its working directory set to the currently browsed directory regardless of whether the background or a subdirectory is clicked.
This means that if a file or subdirectory is right-clicked, lpDirectory should be set to the item's parent directory rather than the item itself.

I have attached a patch with a change that seems to fix the problem.
TagsNo tags attached.
Fixed in Revision7456
Operating systemWindows
Attached Filespatch file icon ushellcontextmenu.pas.patch [^] (533 bytes) 2017-03-16 17:15 [Show Content]

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2017-03-16 17:15 forbjok New Issue
2017-03-16 17:15 forbjok File Added: ushellcontextmenu.pas.patch
2017-03-17 20:05 Alexx2000 Fixed in Revision => 7456
2017-03-17 20:05 Alexx2000 Assigned To => Alexx2000
2017-03-17 20:05 Alexx2000 Status new => resolved
2017-03-17 20:05 Alexx2000 Resolution open => fixed
2017-03-17 20:05 Alexx2000 Fixed in Version => 0.8.0
2017-03-17 20:05 Alexx2000 Target Version => 0.8.0
Get Double Commander at Fast, secure and Free Open Source software downloads

Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker