views:

27

answers:

2

I am trying to package a com dll in an msi. I want the setup to run a batch file afterwards. The batch file basically points to the WINDOWS\Microsoft.NET\Framework\v2.0.50727 folder and runs the regasm command to register the assembly.

How do I get the setup to do this?

Thanks.

+1  A: 

You can't run batch files straight from a VS setup project, but I think you can run scripts that can execute them. Something like this might work:

Set s = CreateObject( "WScript.Shell" )
cmd = "yourbat.bat"
s.Run ("cmd /C " & """" & command & """")
Set s = Nothing

This might not work on all computers though if they don't have the script host installed already, so it might be better to come up with a non batch file way.

Edit: Just remembered a possibly better way of doing this.

I think it would work to, on your pc run RegAsm with the /regfile parameter which creates a regfile containing all the settings needed. Then just add that regfile to your setup project and you won't have to run RegAsm on the client's computer.

ho1
where do I write that script?
@daemonkid - in a file and then create a custom action to execute that file. However, please see my updated answer since I think there's a better solution.
ho1
+1  A: 

A VS Setup project already knows how to register a ComVisible assembly. Set the Register property of the DLL to "vsdrpCOM". No additional post-install commands are needed.

Hans Passant
Thanks. The component got registered as well and can be seen in the registry. I have even put the [Guid("")] and [ComVisible(true)] attributes for both the interface and implementing classes in the dll. In the project properties I have also checked 'Register for interop'However, the calling application still gets this error.“Unable to Create OLE object”What could be the problem?
Iv even set the register property as mentioned above..
Well, it is not a registration problem. Weird message btw, it is not a standard COM error.
Hans Passant