Click here to Skip to main content
13,346,895 members (26,274 online)
Click here to Skip to main content
Add your own
alternative version


8 bookmarked
Posted 15 Dec 2009

Windows 7 workaround to drag & drop DLLs to GAC

, 15 Dec 2009
Rate this:
Please Sign up or sign in to vote.
Drag & drop libraries to install and delete DLLs on Windows 7.


I develop in Visual Studio, and I'm switching from XP on my workstation to Window 7 x64. One thing that annoyed me was that I can’t simply drag .NET library DLLs to the assembly folder to install them in the GAC, or select and delete them from the assembly folder to remove them from the GAC, as I had done on Windows XP. When I try to, I get an ‘access denied’ error, even though my domain login is in the Administrators group, and even though I start Windows Explorer with ‘Run as administrator’.

Apparently, Microsoft really wants you to create installation applets to install or remove libraries in the GAC. An alternative is to log on as the actual machine administrator, in which case, drag and drop to the GAC will work.

I like being able to easily add or delete libraries to the GAC on a development workstation, however, so I came up with a work-around to let me do this.


The method is to create .bat command files that use gacutil.exe to add or delete the library, to capture the name of the library when the library file is dragged to the command file, and have the command file run as administrator. Windows 7 doesn’t allow you to set a .bat command file to run as administrator, so a shortcut is created for each command file, and the shortcut is set to run as administrator.

Using the Code

This method requires gacutil.exe. If you've installed Visual Studio, it should be somewhere on your PC. After installing Visual Studio 2008 on Windows 7 x64, I found it at: C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin. I've also found it at C:\Windows\Microsoft.NET\Framework\v1.1.4322 on a machine with XP and Visual Studio 2005. I copy gacutil to the same folder where I put the command files, for convenience (I use c:\bin).

Here's the code for the AddToGAC.bat command file that installs the library:

c:\bin\gacutil.exe /i %1

Here's the code for the DeleteFromGAC.bat command file that deletes the library:

c:\bin\gacutil.exe /u %~n1

Note that the pause statement is optional. AddToGAC.bat uses the complete path\name of the library file that was dragged and dropped, found in the %1 variable (the path\name becomes the first command parameter). DeleteFromGAC uses %~n1 to parse the file name (without the file extension) from the path\name, which is what gacutil wants to delete a library.

I found info on parsing the path\name command parameter here:

The last step is to create a shortcut to each of the command files on the desktop. Open the properties of each shortcut, click 'Advanced', and select 'Run as administrator'.

When you drag and drop a .NET strong-named library to the Add To GAC shortcut, the User Account Control dialog box will appear (it may me minimized). Click 'Yes', and the library will be added to the GAC. Likewise, when you drag and drop a library to the Delete From GAC shortcut, the same thing will happen, and the library will be removed from the GAC. Unfortunately, you can't drag the library from the assembly folder to delete it, you have to drag it from somewhere else - Windows won't allow dragging and dropping from the GAC.

Points of Interest

I'm a newbie on Window 7, so there may be a better way to do this. One thing I'll look into is if a policy setting somewhere could grant my domain user login rights to do this directly, as though I had logged on as the machine's administrator.

Please feedback if anyone has a better way.


This article, along with any associated source code and files, is licensed under A Public Domain dedication


About the Author

Chuck Bevitt
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

Questiondoesn't work man Pin
h_j_shakib20-Jun-13 8:41
memberh_j_shakib20-Jun-13 8:41 
QuestionThank you! Pin
wbrussell19-Apr-13 8:19
memberwbrussell19-Apr-13 8:19 
QuestionSorry , it does not work for my system. Pin
Member 807340310-Jul-11 19:42
memberMember 807340310-Jul-11 19:42 
GeneralMy vote of 5 Pin
PrimeCipher1-Mar-11 12:11
memberPrimeCipher1-Mar-11 12:11 
AnswerYou have to change a setting in the Local Security Policy Pin
Eric Murriguez18-Jun-10 14:23
memberEric Murriguez18-Jun-10 14:23 
GeneralMy vote of 1 Pin
data4use18-Dec-09 14:42
memberdata4use18-Dec-09 14:42 
GeneralMy vote of 1 Pin
Michael Chourdakis16-Dec-09 13:21
memberMichael Chourdakis16-Dec-09 13:21 
QuestionCan also turn User Account Control off Pin
Chuck Bevitt16-Dec-09 8:41
memberChuck Bevitt16-Dec-09 8:41 
GeneralSimple approach Pin
Conchur15-Dec-09 23:59
memberConchur15-Dec-09 23:59 
GeneralRe: Simple approach Pin
Chuck Bevitt16-Dec-09 8:28
memberChuck Bevitt16-Dec-09 8:28 
GeneralRe: Simple approach Pin
PrimeCipher1-Mar-11 12:09
memberPrimeCipher1-Mar-11 12:09 
QuestionHow we do it Pin
jw12315-Dec-09 23:12
memberjw12315-Dec-09 23:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 16 Dec 2009
Article Copyright 2009 by Chuck Bevitt
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid