我的VS解决方案中有3个项目.其中一个是Web应用,第二个是Windows服务,最后一个是我的Web应用的安装项目.
我想要的是在我的安装项目中的web应用安装结束时,在我的自定义操作中try 并安装我的windows服务,因为那时我已经知道程序集的位置.
我的VS解决方案中有3个项目.其中一个是Web应用,第二个是Windows服务,最后一个是我的Web应用的安装项目.
我想要的是在我的安装项目中的web应用安装结束时,在我的自定义操作中try 并安装我的windows服务,因为那时我已经知道程序集的位置.
好的,这是真正对我有用的东西,它已经在多台具有不同操作系统(Vista、XP、Win2k、Win2003 server)的机器上进行了测试
这段代码是从here开始的,所以写这段代码的人将获得全部荣誉.
将dll或源文件添加到项目中后,请确保添加ServiceTools命名空间,然后您就可以访问一些非常方便的功能,例如...
//Installs and starts the service
ServiceInstaller.InstallAndStart("MyServiceName", "MyServiceDisplayName", "C:\\PathToServiceFile.exe");
//Removes the service
ServiceInstaller.Uninstall("MyServiceName");
//Checks the status of the service
ServiceInstaller.GetServiceStatus("MyServiceName");
//Starts the service
ServiceInstaller.StartService("MyServiceName");
//Stops the service
ServiceInstaller.StopService("MyServiceName");
//Check if service is installed
ServiceInstaller.ServiceIsInstalled("MyServiceName");
我希望这能帮到你.