Copy Path Shell Extension

I created a File Link shell extension in C++ a while back that allows you to copy path-info (full path, location, filename, UNC) for one or more files to the clipboard . I wanted to learn how to create shell extensions in .NET so I rewrote the util which implements the IContextMenu and IShellExtInit interfaces in .NET 2.0. I plan to cleanup the code and create a codeproject article but that task always falls to the bottom, so I'm providing the util without code in case anyone finds it useful.

  • Run the Copy Path Setup. This installs the Copy Path shell extension.
     
  • Open Explorer and select one or more files. Display the context menu and notice the new Copy Path menu. A preview of the path-info text that will be copied to the clipboard is displayed in the Explorer statusbar. Click a menu to copy the path-info to the clipboard.
  • Some find it useful to display the path-info text directly in the context menu. You can do that by selecting Options and checking Display results in menu. The path-info can get quite long and you can truncate the menu text by checking Truncate long paths in menu. Note that the entire path is still copied to the clipboard, just a shorter string is displayed in the menu.
  • Now the path-info is displayed directly in the context menu. Note that the info for the first file is used if multiple files are selected.

Let me know if you have any problems or suggestions.

posted on Thursday, September 28, 2006 9:39 AM by ralph

Comments

# re: Copy Path Shell Extension

Great idea, this is exactly what I need!

Thanks,

Alex
Thursday, September 28, 2006 12:04 PM by Alexander Groß

# re: Copy Path Shell Extension

Tim Sneath posted a tip that this feature is built into Vista, by shift-right click.
http://blogs.msdn.com/tims/archive/2006/09/18/761096.aspx

Thursday, September 28, 2006 3:58 PM by Alan Le

# Interesting Finds: September 28, 2006

Thursday, September 28, 2006 8:37 PM by Jason Haley

# Interesting Finds: September 28, 2006

Thursday, September 28, 2006 8:41 PM by Jason Haley

# re: Copy Path Shell Extension

Really, this is very nice.

I've always wanted to create something like that for myself (also C#) but didn't had the time.

Thanks.
Friday, September 29, 2006 12:42 AM by Khelb

# re: Copy Path Shell Extension

Really cool. I've been using ClipPath, but I like that you've got the path and location (plus UNC).

Feature request: another option at the root level, next to Copy Path, that didn't have any options. 90% of the time I want to copy the entire path, or I'd just hit F2 / Ctrl-C.

So:
Copy Full Path
Copy Path -> Other options
Saturday, September 30, 2006 11:06 PM by Jon Galloway

# re: Copy Path Shell Extension

I installed successfully on a 64 bit machine but it does not appear when I right-click. Any ideas? Thanks.
Friday, October 06, 2006 5:20 AM by Rob

# re: Copy Path Shell Extension

Sorry Rob, I’m not sure right off. I’ll look into it when I have access to 64 bit machine.
Friday, October 06, 2006 1:22 PM by Ralph Arvesen

# San Diego User Group (8/22/06) - Toolbox Meeting

On Tuesday I was one of several presenters at theSan Diego .NET User Group'ssecond annual Toolbox
Monday, October 09, 2006 8:35 AM by JonGalloway.ToString()

# re: Copy Path Shell Extension

Thanks, this works great!
Thursday, October 12, 2006 6:42 AM by Elijah

# re: Copy Path Shell Extension

Can I have the unmanaged version please? I do not have .net on my machine and I have no plans to install it in the near future.
Monday, December 18, 2006 10:11 PM by Agnel

# Checkout the Copy Path Shell Extension

Monday, January 29, 2007 6:12 AM by Robin Debreuil's Blog

# re: Copy Path Shell Extension

Ralph,

Any concern with the ongoing discussion of the CLR hosting issues under Windows Explorer? See http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1174777&SiteID=1&mode=1&PageID=1 for more.

Thanks,
Colin
Wednesday, January 31, 2007 12:54 PM by Colin Bowern

# re: Copy Path Shell Extension

>Any concern with the ongoing discussion of the CLR hosting issues under Windows Explorer?

I was concerned by that, and also another thing.

They always told us not to write Shell Extensions in .NET because of amount of time and memory it takes to initialize CLR at any boot. At least on a clean XP machine, the CLR is off by default. So my concern is: if I write a .NET shell extension for ANY file, than the first time user right clicks on a file, it will suffer the delay of loading the CLR.

Any idea about that? On Vista, is the CLR run at boot?

Monday, March 26, 2007 1:07 AM by Alessio

# re: Copy Path Shell Extension

> 64 bit issues, shell extension CLR issues
Thanks for all of the great questions. I apologize I don't have any time to look into this utility at this time and answer the questions. I wanted to at least respond and say I hear you, but I don't know.
Monday, April 09, 2007 2:24 AM by Ralph Arvesen

# filenames or paths with whitespaces

Hi, a usefull extension. Installed it right away. Enhancement is still possible! When you have paths or filenames with whitespaces, the link is not properly displayed. A workaround is to enclose the link in brackets. For example : <\\somepc\someshare\some path\some file.txt>
Thursday, July 12, 2007 5:02 AM by Pascal

# Mikes Links Monday 8/27/07

Mikes Links Monday 8/27/07
Friday, August 24, 2007 1:22 PM by mikedopp.com

# Mikes Links Monday 8/27/07

Mikes Links Monday 8/27/07
Friday, August 24, 2007 1:23 PM by mikedopp.net

# Mikes Links Monday 8/27/07

Mikes Links Monday 8/27/07
Friday, August 24, 2007 2:01 PM by mikedopp.com

# Mikes Links Monday 8/27/07

Mikes Links Monday 8/27/07
Monday, August 27, 2007 8:35 AM by mikedopp.com

# re: Copy Path Shell Extension

Hi,

I always wanted to develop this kind of utility. Ralph thanks, great job !!!

Sincerely,
Eli Zeitlin
Senior Software Engineer (Jerusalem, Israel)
Thursday, September 06, 2007 12:22 AM by Eli Zeitlin

# re: Copy Path Shell Extension

Could you please post the .net source code.
Thanks,
Jay Johnson
jjmi50[at]gmail.com
Tuesday, September 11, 2007 10:12 AM by Jay Johnson

# re: Copy Path Shell Extension

Thanks Ralph, this is really useful.
Tuesday, November 13, 2007 4:12 AM by Peter

# re: Copy Path Shell Extension

Please post the code (cleaned up or otherwise) when you get the chance - I'd like to see how it works...
Tuesday, November 13, 2007 4:16 AM by Peter

# re: Copy Path Shell Extension

This is a very useful utility, and now that I have a 64-bit machine, I can respond to the 64-bit issues.

The problem is that 64-bit Windows sees the 32-bit installer and redirects the Registry entries to the Classes\Wow6432Node\CLSID key instead of the Classes\CLSID key (even though the installed application is .NET-based).

If you installed CopyPath into the default directory ("C:\Program Files (x86)\Copy Path\"), you can download this .reg file and Merge it into your Registry to create the necessary entries. (If you installed it to a different path, edit the paths in the file before merging it.)

http://www.skst.com/files/copypath_x64.zip
Monday, November 19, 2007 1:17 PM by Stefan Tucker

# re: Copy Path Shell Extension

Thanks for this little jewel! Its exactly what i was looking for for my staff (they just weren't understanding file paths so this will really help when passing files around on the LAN!)
Tuesday, December 04, 2007 10:49 PM by Gaiko

# re: Copy Path Shell Extension

Thanks for making such a great extension. I am trying to get my co-workers out of the bad habit of emailing files that exist on the network to avoid two versions floating around. This extension will certainly help supplement my nagging.

The only problem that I am having is, that after installing the extension, my ability to open or print multiple files through explorer (via the context menu) no longer works. I sometimes need to open a bunch of files en masse and being able to do this in explorer is essential to me, but I would love to be able to use the copy path extension too.

I am running XP Pro, .net is updated, tried versions 2 and 3, etc. When I disable the extension using ShellExView, my ability to open and print multiple files at once is restored. When I re-enable it, my functionality goes away.

Any ideas that might get both working for me? Thanks again for creating such a handy tool.
Tuesday, December 11, 2007 7:35 AM by James

# re: Copy Path Shell Extension

Hi,

Is there a way to install it silently for all users on the computer ?

Regards,

Mike
Thursday, January 17, 2008 5:34 AM by SeYo

# re: Copy Path Shell Extension

Even though the Registry modification I describe above gets CopyPath running on 64-bit Windows, CopyPath doesn't add its menu commands. So I used that as an excuse to write my own .NET-based extension. (I know people say not to use .NET for shell extensions, but I've used C++ to do it before and it's so much easier to do in .NET!)

My implementation's a bit different from CopyPath. PathToClipboard supports more than one selected object and can follow shortcuts. It doesn't bother with UNC, but I might add that later if I need it (or if enough people request it).

Path To Clipboard:
http://www.12noon.com/pathtoclipboard.htm
Friday, February 01, 2008 10:06 AM by Stefan

# re: Copy Path Shell Extension

Hi there at Vertigo. Nice extension! Is there an easy way to translate it (e.g. into German)?

Greets from munich,
magoo
Thursday, February 28, 2008 3:47 AM by magoo [ i.am.magoo at gmail dot com ]

# re: Copy Path Shell Extension

Seriously, man.. thanks. You saved me a day of work. I was going to write one on my own but now that work I don't have to do :)

Much Thanks!
Monday, March 24, 2008 7:08 AM by Joe

# re: Copy Path Shell Extension

I would just like to add my thanks - this tool has saved me many hours!

I can second some of the commments above, so if you are ever thinking of updating, here are my suggestions ;)

UNC to URL Encoding - Maybe not a full URLEncode, but at least so:
'\' converted to '/'
'space' converted to '%20'
'\\' converted to 'file://///'

I think someone else already mentioned this one, but it would be great if there was an option of wrapping UNC paths with < > (but only if they contain spaces). - This is so that MS Office software including Word, Outlook & Outlook Express treat the whole string as a URL, instead of only making the first part into a URL.
e.g.
'\\server\file name' = FAIL - only first part will become a URL
'<\\server\file name>' = SUCCEED - the entire string is converted to URL and the '<' & '>' are removed automatically.

Anyway, just 2 suggestions, again thanks for the great extension!

~Peter
Thursday, April 17, 2008 5:22 AM by Peter

# re: Copy Path Shell Extension

I finally was so fed up with Windows not having something like this built-in that I finally Googled for something like this. This is awesome! For years I thought of the idea but never got around to it... and I'm glad you did it for everyone. Keep up the good work!
Monday, April 21, 2008 2:56 PM by smu johnson

# re: Copy Path Shell Extension

Ralph you are a champion. This tool is essential in Windows. Unfortunately I am on 64-bit Vista, and although your .reg file does at least make the shell extension menu appear, whenever I select any of the sub-items (e.g. to copy the path or go to the options dialog), explorer.exe crashes:

Problem signature:
Problem Event Name: APPCRASH
Application Name: Explorer.exe
Application Version: 6.0.6001.18000
Application Timestamp: 4791970c
Fault Module Name: StackHash_4cdf
Fault Module Version: 6.0.6001.18000
Fault Module Timestamp: 4791adec
Exception Code: c0000374
Exception Offset: 00000000000a6e97
OS Version: 6.0.6001.2.1.0.256.6
Locale ID: 3081
Additional Information 1: 4cdf
Additional Information 2: 0c5ccd43e7233a8a356460e289b18c5e
Additional Information 3: 730c
Additional Information 4: 3a2d12c6812e2dcc4f153110a8b421b4

If you have time to check this out I'm sure many people would be appreciative.

Thanks again.
Tuesday, June 10, 2008 3:32 PM by Peter