Monday, August 23, 2010

How to get the files from GAC in Windows

This is what I think about since I started working on Windows. I don't know how to see the Windows GAC files and get them for other use. For example, sometimes I deploy the files to GAC location and then want to move the same dll to some other server. But, as usual, the original files missed from the file system. The only location I can get them is GAC. But, don't know how to get the files from GAC. This is a big question and resolved my my colleague Phani recently. I was surprised and felt very happy after the resolution he found and now I am utilizing it very efficiently.
There is a command available in Windows for doing the task. "subst".

The command will create a virtual folder of all GAC files to a separate drive. Below is the syntax:
subst Z: C:\windows\Assembly
When you go to the my computer you will find a new drive under the regular drives. Just go inside and you can see all the GAC files. The folder GAC_MSIL is what your all files reside in. Copy the dll's you needed and paste them in some safe location for backup.

To remove the Z drive from machine, then use below command.
subst Z: /D
All credits goes to Phani and take a look at this post from him for more information. Enjoy some nice tips and rare findings from the blog.

4 comments:

  1. You can try this -
    Set HKLM\Software\Microsoft\Fusion\DisableCacheViewer to 1.

    If the value does not exist then we can create it.

    ReplyDelete
  2. I don't mean to be pedantic but just to ease confusion the above technique creates essentially a drive mapping to a virtual folder it does not create a copy.

    Disabling the CacheViewer is just as easy an approach if you need to get dlls would probably put the setting back afterwards.

    ReplyDelete
  3. Thanks for the comment. I have updated the post by removing "copy" word in it.

    ReplyDelete
  4. You can also do it from a run command (WindowsKey-R) and enter "c:\windows\assembly\gac_msil"

    ReplyDelete