Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
Gnostice Document Studio .NET |
PDFOne .NET |
Gnostice Document Studio Java |
PDFOne (for Java) |
Gnostice Document Studio Delphi |
eDocEngine VCL |
PDFtoolkit VCL |
StarDocs Web APIs |
If you work in a big company or if your files are scattered over several server shares, then you may often find yourself copying the path or the name of a file in Windows Explorer. The steps involved are simple but it may seem cumbersome when you do it several times a day.
If I am right, then you will be happy to know that you can use some context menu (shortcut menu) options to reduce the number of steps. In Windows XP, there are no such menu options. In Windows Vista and Windows 7, you can hold the SHIFT key and then right-click on a file to get a "Copy as path" context menu option. Unfortunately, this option has some limitations. Here are some:
At the bottom of this page, you can download two simple utilities that will provide more user-friendly context menu options. I had originally created them for my colleagues. I have seen the menu extensions working in Windows XP and Windows 7. I expect the extensions to work in Windows Vista also. However, these utilities were a personal project and are not endorsed or supported by Gnostice. For this reason, I have decided to provide full source code so that you can compile the utilities yourself. Test them. If it works, use them.
When the utilities are installed properly, Windows Explorer will get four new context menu options. Two of the menu options will be available for files and the other two will be for folders. These options will allow you to copy the path or the name of the file or folder that you have right-clicked.
The download zip file contains two folders. Each folder contains a small application written in Visual Basic 6, a .reg
installer file, a .reg
uninstaller file, and a readme text file.
The first utility is simply called Copy Pathname (arg2cp.exe). It copies path of the selected file or folder to clipboard. The second utility is called Copy Filename (arg2cn.exe). It copies the name of the selected file or folder to the clipboard. These applications are meant to be invoked by Windows Explorer. If you try to invoke them independently, you will get nothing but an error message.
The .reg
files are used in place of regular installation and uninstallation programs. The registry files create certain entries in the Windows Registry store. These entries cause Windows Explorer to provide the custom context menu options displayed above. When a user right-clicks a file or folder and selects one of the menu options, Windows Explorer will send the full path of the file or folder to the application (either arg2cp.exe or arg2cn.exe) specified by the relevant registry entry. The application processes the file/folder path information and copies the processed information to the clipboard.
Here are the contents of the .reg
file installer of the first utility.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\Shell\Copy File Path\Command] @="\"C:\\Program Files\\Copy Pathname\\arg2cp.exe\" \"%1\"" [HKEY_CLASSES_ROOT\Directory\Shell\Copy Folder Path\Command] @="\"C:\\Program Files\\Copy Pathname\\arg2cp.exe\" \"%1\""
And, here are the contents of the .reg
file installer of the second utility, which copies the name of the selected file or folder.
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\Shell\Copy File Name\Command] @="\"C:\\Program Files\\Copy Filename\\arg2cn.exe\" \"%1\"" [HKEY_CLASSES_ROOT\Directory\Shell\Copy Folder Name\Command] @="\"C:\\Program Files\\Copy Filename\\arg2cn.exe\" \"%1\""
You can copy these registry entries to Notepad and save the file with a .reg
extension. You can use that file as your installer. Now, here is the VB6 source code for the arg2cp.exe.
Attribute VB_Name = "Module1" Sub main() Dim strPathname As String strPathname = Command strPathname = Right(Command, Len(Command) - 1) strPathname = Left(strPathname, Len(Command) - 2) Clipboard.Clear Clipboard.SetText (strPathname) End Sub
Here is the VB6 source code for the arg2cn.exe.
Attribute VB_Name = "Module1" Sub Main() Dim strPathname As String strPathname = Command strPathname = Right(Command, Len(Command) - 1) strPathname = Left(strPathname, Len(Command) - 2) strPathname = Right(strPathname, Len(strPathname) - InStrRev(strPathname, "\")) Clipboard.Clear Clipboard.SetText (strPathname) End Sub
There is no error-checking code because I trust Windows Explorer to pass file path information without any errors.
Copy Pathname
and Copy Filename
.
C:\Program Files
. Please be careful. The folders need to be created only under the C:\Program Files
folder. If you wish to extract the folders to some other folder, then the installer .reg
files need to be suitably modified first. Please be reminded that the new path in the .reg
file need to be escaped properly. Mistakes can be costly. The installer .reg
file that I have provided has been directly exported from my registry and is always expected to work, provided that you have correctly followed all my installation instructions.C:\Program Files\Copy Pathname
or the C:\Program Files\Copy Filename
folder..reg
file to display the context menu and select the Merge option. This will launch Registry Editor..reg
file, select Yes, and later select OK to finish the installation.To uninstall one of these context menu extensions, navigate to the C:\Program Files\Copy Pathname
or the C:\Program Files\Copy Filename
folder in Windows Explorer and run the Uninstall_Copy_Pathname.reg
or Uninstall_Copy_Filename.reg
file.
The Uninstall_Copy_Pathname.reg
reg file contains the following:
Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\*\Shell\Copy File Path] [-HKEY_CLASSES_ROOT\Directory\Shell\Copy Folder Path]
The Uninstall_Copy_Filename.reg
reg file contains:
Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\*\Shell\Copy File Name] [-HKEY_CLASSES_ROOT\Directory\Shell\Copy Folder Name]
These uninstaller .reg
files delete the registry entries that were originally created by the installer .reg
file and Windows Explorer will no longer show those additional context menu options.
Sometimes, you may see two redundant menu options for ZIP files. This may be because you have installed Compressed Folders utility that comes with Windows. Compressed Folders makes Windows Explorer treat ZIP files as folders. To avoid this awkwardness, you can either uninstall the menu extensions or uninstall Compressed Folders. To uninstall Compressed Folders, use the following command in the Run dialog box of the Windows Start menu.
regsvr32 /u %windir%\system32\zipfldr.dll
Uninstalling Compressed Folder has another positive side effect - your file search operations become faster as it no longer searches inside zip files! However, to open zip files in the absence of Compressed Folders, you may wish to install a freeware zip utility such as IZarc and set it as the default application for file archive formats.
If you wish to restore Compressed Folders at a later point in time, enter the following commands, one after another, in the Run dialog box.
regsvr32 %windir%\system32\zipfldr.dll rundll32 zipfldr.dll,RegisterSendto
There have been few requests for adding more features to this utility. I would rather recommend Path Copy Copy project, which has more features.
---o0O0o---
Our .NET Developer Tools | |
---|---|
![]() Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
![]() PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
![]() Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
![]() eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
![]() PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
![]() Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
![]() PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
![]() StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2023 Gnostice Information Technologies Private Limited. All rights reserved. |