Wednesday, October 5, 2005

Start Application Automatically After Setup

I wanted to automatically run my application after setup completed. I searched high and low for this option and it just isn't included in the Setup Project options for Visual Studio.NET 2003. It looks like it will be in 2005 though. Here is the easy way to do it

  1. Add an installer class to your application with the following code:
    [sourcecode language='vb']
    Public Overrides Sub Install(ByVal stateSaver As IDictionary)
    MyBase.Install(stateSaver)
    Dim Asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
    System.Diagnostics.Process.Start(Asm.Location)
    End Sub
    [/sourcecode]

  2. Right click on your setup project and go to View - Custom Actions

  3. Right click on Install under Custom Actions and select Add Custom Action...

  4. Select the primary output of your project from the application folder

  5. Do the same for the Commit


That's it. Your installer will now run your application after setup.

No comments:

Post a Comment