I'm working on an ASP.NET project where I've a bunch of dlls created in a folder. I need to write a cmd or bat file to take all the dlls in that folder and GACUTIL it. So how can loop all the dlls in a folder?
Asked
Active
Viewed 2,131 times
1
-
1Use a `FOR` loop. Run `FOR /?` for all the gory details. – Gabe Jun 20 '11 at 05:40
2 Answers
2
This is what I am using to deploy all sql files in a given folder, you could adjust it to act on dll files if needs be;
@echo off
SET dbodir=../Schema Objects/Schemas/dbo/Programmability/Stored Procedures/
SET tpmdir=../Schema Objects/Schemas/TPM/Programmability/Stored Procedures/
echo --- Starting dbo schema
for %%f in ("%dbodir%*.sql") do (echo Running %%f.... && @sqlcmd -U %1 -P %2 -S %3 -d %4 -i "%dbodir%%%f")
echo --- Completed dbo schema
echo --- Starting TPM schema
for %%g in ("%tpmdir%*.sql") do (echo Running %%g.... && @sqlcmd -U %1 -P %2 -S %3 -d %4 -i "%tpmdir%%%g")
echo --- Completed TPM schema
pause

Mr Moose
- 5,946
- 7
- 34
- 69
0
If anybody is looking for the powershell way of doing it.
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$dlls = Get-ChildItem -Path C:\Code\Application\ -Filter *dll -Recurse -ErrorAction SilentlyContinue -Force | %{$_.FullName}
foreach ($dll in $dlls) {
$publish.GacInstall($dll)
}

Ziaullah Khan
- 2,020
- 17
- 20