Powershell Script Install / Uninstall GAC DLL (2024)

Most of the server environments lack the gacutil.exe as it is part of Visual Studio installation. In such scenarios the below PowerShell script does the job to install / uninstall DLLs from GAC.

Install Script

#Install DLL in GAC[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") $publish = New-Object System.EnterpriseServices.Internal.Publish $publish.GacInstall("C:\PathOnServer\DLL.dll")

Uninstall Script

#Uninstall DLL in GAC[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") $publish = New-Object System.EnterpriseServices.Internal.Publish $publish.GacRemove("C:\PathOnServer\DLL.dll")

Steps to Run the script

-Open the Windows PowerShell ISE from the Administrative tools on the server.

-Copy below script to the script pane. (If you don’t see the script pane. Tool -> Show Script Pane)

-Replace the C:\PathOnServer\DLL.dll with the actual path of the DLL.

-Run the script. Press (F5) or click on Green Run Icon on ToolBar.

Powershell Script Install / Uninstall GAC DLL (2024)

FAQs

How to uninstall dll from GAC using command prompt? ›

Use "gacutil /u" to remove the desired assemblies from the GAC.

How do I get DLL out of GAC? ›

Get DLL Out of The GAC
  1. Run regsvr32 /u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll. ...
  2. Open “%windir%\assembly\GAC_MSIL”.
  3. Browse to your DLL folder into the deep to find your DLL.
  4. Copy the DLL somewhere on your hard disk and refer it from there in your project.
  5. Run "regsvr32 %windir%\Microsoft.NET\Framework\<.
Apr 3, 2009

How do I delete an assembly from GAC? ›

Removing the assembly from GAC
  1. Start the . ...
  2. Select Assembly Cache from the tree view on the left.
  3. Click the View List of Assemblies in the Assembly Cache link.
  4. Find Sybase. ...
  5. Select one or more assemblies to remove. ...
  6. Check for the publisher policy files that correspond to the versions removed and remove these files too.

Where is the GAC in PowerShell? ›

The list of assemblies stored in the Global Assembly Cache (GAC) can be found in the registry under the HKEY_CLASSES_ROOT\Installer\Assemblies\Global key. The first line registers a new drive called HKCR in PowerShell that maps to the HKEY_CLASSES_ROOT in the registry.

How to run gacutil.exe from command prompt? ›

  1. Run the .NET command prompt (Start >> Programs >> Microsoft VS.NET >> VS.NET Tools >> VS.NET prompt)
  2. Start the gacutil.exe tool with -i parameter (install) and the full path to the control's DLL. For example: gacutil.exe -i "C:\Program Files (x86)\Progress\Telerik UI for WinForms "Version"\bin40\TelerikCommon. dll"

How to clean up GAC? ›

There are two ways to remove an assembly from the global assembly cache (GAC): By using the Global Assembly Cache tool (Gacutil.exe). You can use this option to uninstall assemblies that you've placed in the GAC during development and testing. By using Windows Installer.

How to delete DLL files from command prompt? ›

Alt-Tab to command prompt. Execute “del /f <filename>” where /f is an option specifying force delete and <filename> is the entire path to the file, including its name.

What is the Global Assembly Cache in PowerShell? ›

The Global Assembly Cache (GAC) is a machine wide repository for . Net Assemblies. PowerShell GAC provides several PowerShell commands to view and modify the GAC. PowerShell GAC works standalone and does not depend on tools like gacutils.exe.

How to unregister dll using CMD? ›

How to manually unregister a DLL file
  1. Click Start > Run (or use the Windows command line: Search > CMD > Right click - Run as Administrator)
  2. Type REGSVR32 /U "C:\Blackbaud\DLL\[filename.dll]" For example, to unregister SQLDMO.dll type, REGSVR32 /U "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLDMO.dll" ...
  3. Click OK.

What is GAC installation? ›

The global assembly cache (GAC) stores assemblies that several applications share. Install an assembly into the global assembly cache with one of the following components: Windows Installer. Global Assembly Cache tool.

Where is the GAC folder in Windows? ›

The GAC is located in the following folder: C:\Windows\Microsoft.NET\assembly\GAC_MSIL.

How do you disable the assembly cache viewer and see the GAC? ›

If you want to disable the Assembly Cache Viewer and see the GAC in all its naked glory within Windows Explorer, you can set HKLM\Software\Microsoft\Fusion\DisableCacheViewer [DWORD] to 1.

How to register a DLL file in PowerShell? ›

How to Register DLL/OCX with PowerShell?
  1. When the scripts are created, we navigate to the Custom Actions page.
  2. Search for the Run PowerShell script file predefined Custom Action and add it in the sequence.
  3. Once we select the registration PowerShell script, we can proceed to configure the Custom Actions as follows:

Where is the Gacutil located? ›

The Gacutil.exe tool is located in the . NET Framework installation directory. The default location for this is C:\Program Files (x86)\Microsoft SDKs\Windows\v10. 0A\bin\NETFX 4.6.

How to unregister DLL using CMD? ›

How to manually unregister a DLL file
  1. Click Start > Run (or use the Windows command line: Search > CMD > Right click - Run as Administrator)
  2. Type REGSVR32 /U "C:\Blackbaud\DLL\[filename.dll]" For example, to unregister SQLDMO.dll type, REGSVR32 /U "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLDMO.dll" ...
  3. Click OK.

How do I open uninstall programs from command prompt? ›

how to uninstall a program using CMD or Power Shell ?
  1. CMD: wmic. product get name. ...
  2. Power Shell: $app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -match “Software Name” } >> $app.Uninstall()
Feb 28, 2019

Top Articles
Latest Posts
Article information

Author: Fr. Dewey Fisher

Last Updated:

Views: 6564

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Fr. Dewey Fisher

Birthday: 1993-03-26

Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

Phone: +5938540192553

Job: Administration Developer

Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.