I have a bunch of dlls in a folder, which are either COM dlls
, or .NET assemblies
. Now, I'm using something like this below to register the binaries:
@echo off
set argCount=0
for %%x in (%*) do (
set /A argCount+=1
)
if not %argCount% == 1 (
echo Usage:
echo %0 ^<filename^>
echo Example:
echo %0 path\to\the\file.ext
goto end
)
for /F "tokens=*" %%A in (%1) do (
echo Registering %%A ...
regsvr32 "%%A"
)
:end
The issue here is that although for COM dlls, it works fine, but for .NET assemblies it fails. As a workaround, I could replace the regsvr32
with regasm
and run it again. This would, in the second run register the .NET assemblies. I was wondering, if there was a way the batch file might be able to distinguish between the two cases here. I understand, COM dlls must have the PE
or COFF
header while .NET assemblies would not (?). Looking at MSDN, I see ImageHlp API which might have something for this. Is there an easier way to achieve the same?