Automatically start application after installation

Add installer class to the project. This code snippet will start the application immediately after it is installed on the computer.


//Namespaces to be included

//For getting directories
using System.IO;

//For starting the application
using System.Diagnostics;

//For getting assembly path
using System.Reflection;



private void Install_Power_Committed(object sender, InstallEventArgs e)
{
//Getting the directory onto which the application is installed.
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

//Executing the application in that acquired directory path.
Process.Start(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location + "\\YourApp.exe"));

}


Comments

Guest Author: Mayada Hafez06 Mar 2013

Is this function 'Install_Power_Committed' should be invoked automatically?
i have added this function but the application couldn't started



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: