Tuesday, February 28, 2012

Bat file to make .net assembely (dll or exe) 32 bit only

Why would you want to do this?

Eg. When on a 64 bit Os and wanting to load/use the 32bit pdf IFilter that comes with Adobe Reader 9. 




Rem Klaus Bjørn Jensen 29/01/2010
Rem Marks an assembely (dll or exe) as 32 bit only. Resigns the assembely with the specified key. 
Rem The original file is not changed but a copy is made with "32" appended to the filename.
REM param1 : Fully qualified path to assembelyDll to register
REM param2 : Fully qualified path to the key file (*.snk)


SET AssembelyName=%~f1
SET SignKey=%~f2
SET NewFileName=%AssembelyName%32


copy "%AssembelyName%" "%NewFileName%"


call "%ProgramFiles%\Microsoft Visual Studio 8\VC\vcvarsall.bat"
corflags "%NewFileName%" /32BIT+ /force
sn -R "%NewFileName%" "%SignKey%"

No comments: