关于.net下服务安装
来源:岁月联盟
时间:2005-01-17
后来在网上找到.net里的几个类,可以用来安装:
TransactedInstaller和AssemblyInstaller
TransactedInstaller是用来安装多个AssemblyInstaller的,我只用AssemblyInstaller就够了!
要引用System.Configuration.Install.dll和
using System.Configuration.Install;
很简单
安装:
AssemblyInstaller myAssemblyInstaller;
myAssemblyInstaller=new AssemblyInstaller();
myAssemblyInstaller.UseNewContext=true;
myAssemblyInstaller.Path="XXXService.exe";
Hashtable mySavedState=new Hashtable()
myAssemblyInstaller.Install(mySavedState);
myAssemblyInstaller.Commit(mySavedState);
myAssemblyInstaller.Dispose();
卸载服务:
AssemblyInstaller myAssemblyInstaller;
myAssemblyInstaller=new AssemblyInstaller();
myAssemblyInstaller.UseNewContext=true;
myAssemblyInstaller.Path="XXXService.exe";
myAssemblyInstaller.CommandLine=new string[1]{"/u"};
myAssemblyInstaller.Uninstall(null);
myAssemblyInstaller.Dispose();
这2个类应该也可以制作一些小的安装程序!
上一篇:c# 获得局域网主机列表实例
下一篇:.NET的自动序列号工具











