22

I have created a setup project using Visual Studio 2008. After the application is finished installing, I would like to have it start up immediately. Any thoughts on how this can be done?

Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
adeel825
  • 5,677
  • 12
  • 40
  • 44

3 Answers3

26

I've used a script to place a checkbox "Launch [ProductName]" on the final form of the MSI. I cannot take any credit for the script though. You can find the script over on Aaron Stebner's blog at MSDN http://blogs.msdn.com/astebner/archive/2006/08/12/696833.aspx

There's an interesting article about it on CodeProject and some good answers there also (which is where I found Aaron's article). http://www.codeproject.com/KB/install/Installation.aspx

Finally, there's also some other similar questions on StackOverflow

How to run executable at end of Setup Project?

How to automatically start my application when my setup is done in C# setup project

Community
  • 1
  • 1
Peter Kelly
  • 14,253
  • 6
  • 54
  • 63
13

I have used a custom action in VS 2005. Not sure if this is enhanced in VS 2008.

Gulzar Nazim
  • 51,744
  • 26
  • 128
  • 170
8

Here's how to make your application launch after install (using VS2010):

Assuming you already have 2 projects like: MyApp.Application and MyApp.Installer.

  1. Right-click the project for MyApp.Application and choose Add > New Item... > Installer Class (name it whatever you want)
  2. Right-click the new Installer class & choose View Code
  3. Override the Commit method like this:

    public override void Commit(IDictionary savedState)
    {
        base.Commit(savedState);
    
        Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
        Process.Start(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\MyApp.exe");
    }
    
  4. Update MyApp.exe to use the name of your application

  5. Right-click your MyApp.Installer project & choose View > Custom Actions
  6. Right-click the Commit folder & choose Add custom action
  7. Choose Application Folder > OK > OK

References:

bendytree
  • 13,095
  • 11
  • 75
  • 91