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?
问题:
回答1:
I have used a custom action in VS 2005. Not sure if this is enhanced in VS 2008.
回答2:
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
回答3:
Here's how to make your application launch after install (using VS2010):
Assuming you already have 2 projects like: MyApp.Application
and MyApp.Installer
.
- Right-click the project for
MyApp.Application
and chooseAdd
>New Item...
>Installer Class
(name it whatever you want) - Right-click the new Installer class & choose
View Code
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"); }
Update
MyApp.exe
to use the name of your application- Right-click your
MyApp.Installer
project & chooseView
>Custom Actions
- Right-click the
Commit
folder & chooseAdd custom action
- Choose
Application Folder
>OK
>OK
References:
- Launching Your Application After Install using Visual Studio 2005
- MSDN: Walkthrough: Creating a Custom Action