Easiest way to use RevSvr32 to unregister all DLLs in a directory

boudog13
boudog13 used Ask the Experts™
on
Greetings Experts,

I am charged with a pretty massive cleanup task.  I have a large number of servers that have a very large number of custom COM objects that have been created and installed.  I'm charged with uninstalling them.  The installer drops these dlls in 5 different directories on a designated drive letter that is determined by which server it is being deployed on.

I would like to write a script or batch command to unregister all dlls in a given directory, or a collection of directories.  I have verified that all of the components do exist on all of the servers.  However, if there's a way to do an "IfExists" on the dll, I would like to include that as well.

My original thinking was a .bat file, but I don't know how to have the user enter a drive letter that serves as the location where the directories are installed.  Is this the best way, or is there an easier way?

I'm in a bit of a time crunch... thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
leakim971Multitechnician
Top Expert 2014

Commented:
Hello boudog13,

Try something like (replace system32\yourdll) :


if exist %Windir%\system32\yourdll.dll %Windir%\system32\regsvr32.exe /s %Windir%\system32\yourdll.dll 

Open in new window

in a batch file it is exactly that "if exists filename.dll", if you are writing a program (vb for example) you can use the file system object to check existence of a file. Let me know if you need more clarification.

Author

Commented:
Thank you both for the quick response.  That's pretty simple...  Is it possible to use a wildcard to loop through all DLLs in a directory without naming them?
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

the wildcard option will test if any exist in the directory if you are writing in code the dir() function allows you to loop through all of the files in a directory, if you want this option I will send you a snippet

Author

Commented:
a snippet would be great... thank you...
Multitechnician
Top Expert 2014
Commented:
With powershell :



ls c:\windows\system32\*.dll | %{regsvr32 /s $_}

Open in new window

Sub FileExistsFuntioncaller()
'sample routine to demonstrate using the myFileExists function
If bwsFileExists("c:\BostonWorkstation\log.txt") Then
    Debug.Print "found"
Else
    Debug.Print "not found"
End If
End Sub
Function myFileExists(pFile As String) As Boolean
'function to determine if a file exists, expects full path & file name as parameters
Dim strCheckFile As String
strCheckFile = Dir(pFile)
If Len(Trim(strCheckFile)) = 0 Then
    myFileExists = False
    Exit Function
Else
    myFileExists = True
End If
End Function
leakim971Multitechnician
Top Expert 2014

Commented:
With a list : c:\dlls.txt (first line is column name, set it to dll)
Import-csv c:\dlls.txt | foreach-object {regsvr32 /s $_.dll}

Open in new window

Author

Commented:
thanks experts.  this was extremely helpful.
leakim971Multitechnician
Top Expert 2014

Commented:
Heu... we're rigth, this is not your real target folder : c:\windows\system32\

Commented:
CD into the directory you need &&

for /r %i in (*.ocx) do regsvr32 /s /u "%i"
 
for /r %i in (*.dll) do regsvr32 /s "%i"


=D

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial