代码之家  ›  专栏  ›  技术社区  ›  adeel825

在Visual Studio安装项目中安装后如何启动应用程序

  •  21
  • adeel825  · 技术社区  · 17 年前

    我使用Visual Studio 2008创建了一个安装项目。应用程序安装完成后,我希望立即启动它。有什么想法可以这样做吗?

    3 回复  |  直到 14 年前
        1
  •  13
  •   Gulzar Nazim    17 年前

    我在 VS 2005 . 不确定这在vs 2008中是否得到了增强。

        2
  •  26
  •   Community Mohan Dere    9 年前

    我使用了一个脚本,在MSI的最终表单上放置了一个复选框“Launch[ProductName]”。不过,我不能相信这部剧本。你可以在艾伦·斯坦布纳的博客上找到剧本。 http://blogs.msdn.com/astebner/archive/2006/08/12/696833.aspx

    有一篇关于代码项目的有趣文章,也有一些很好的答案(这就是我找到亚伦文章的地方)。 http://www.codeproject.com/KB/install/Installation.aspx

    最后,还有一些关于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

        3
  •  8
  •   bendytree    14 年前

    以下是安装后如何启动应用程序(使用VS2010):

    假设您已经有两个项目,例如: MyApp.Application MyApp.Installer .

    1. 右键单击项目 myapp.应用程序 并选择 Add gt; New Item... gt; Installer Class (想叫什么就叫什么)
    2. 右键单击新的安装程序类并选择 View Code
    3. 重写 Commit 方法如下:

      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. 更新 MyApp.exe 使用应用程序的名称

    5. 右键单击您的 MyApp安装程序 项目和选择 View gt; Custom Actions
    6. 右击 提交 文件夹选择 Add custom action
    7. 选择 Application Folder gt; OK gt; 好啊

    参考文献: