How do I launch an application after install in a

2019-01-07 12:08发布

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?

3条回答
2楼-- · 2019-01-07 12:24

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:

查看更多
唯我独甜
3楼-- · 2019-01-07 12:37

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

查看更多
叼着烟拽天下
4楼-- · 2019-01-07 12:37

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

查看更多
登录 后发表回答