开发者

How to run a batch script after installation is finished?

开发者 https://www.devze.com 2023-03-23 17:05 出处:网络
I\'m working for a custom installer developed in Visual Studio 2008 (Setup & Deployment > Setup project) for a C# project. I\'d like to run a batch file (*.bat) after installation 开发者_运维问答i

I'm working for a custom installer developed in Visual Studio 2008 (Setup & Deployment > Setup project) for a C# project. I'd like to run a batch file (*.bat) after installation 开发者_运维问答is finished. How can I do that?


You will have to extend the Installer class and override the Committed event.

Here is an example. Hope you will be able to find how to run a .bat file in C#.

[RunInstaller(true)]
public class ServiceInstaller : Installer
{
    string strServiceName = "MyServiceName";

    public ServiceInstaller()
    {
        // .............

        this.Committed += new InstallEventHandler(ServiceInstaller_Committed);
    }

    void ServiceInstaller_Committed(object sender, InstallEventArgs e)
    {
        // Run your batch file
    }
}

Custom Install Action is another option. Here is a similar thread for that.


You can run a batch file using cmd.exe, anyway it is what executes batch files.

Start it this way: cmd.exe /c <path-to-batch>\batchfile.bat.

0

精彩评论

暂无评论...
验证码 换一张
取 消