安装完成后如何运行批处理脚本?
我正在为一个C#项目的Visual Studio 2008(安装和部署>安装项目)中开发的自定义安装程序工作。 我想在安装完成后运行批处理文件(* .bat)。 我怎样才能做到这一点?
您必须扩展Installer类并覆盖Committed事件。
这是一个例子 。 希望您能够找到如何在C#中运行.bat文件。
[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 } }
自定义安装操作是另一种选择。 这是一个类似的线程。
您可以使用cmd.exe
运行批处理文件,无论如何它都是执行批处理文件的。
以这种方式启动: cmd.exe /c
。