使用.Net编写好了WindowsService以后,不安装到系统里就没有任何作用。
[添加Installer]
在服务的设计器画面,属性页面里,选择[Add Installer]链接。
如此便会生成两个新的组件,ServiceProcessInstaller和ServiceInstaller。
ServiceProcessInstaller组件用来保持服务运行时的账户类型和凭证信息(LocalSystem,LocalUser,User等)。
ServiceInstaller组件用来保持注册表(HKEY_LOCAL_MACHINESystemCurrentControlSetServices)中服务的关联信息,包括 服务名,显示名称,依赖关系,启动类型--自动,手动等。
如果一个工程中有数个服务,则需要分别添加这些服务的ServiceInstaller,并且可以在Install和Uninstall事件中对安装和卸载服务进行额外的处理。
准备完毕后,就可以安装/卸载服务了
InstallUtil Myservice.exe
InstallUtil Myservice.exe /u
参考自:http://www.itmedia.co.jp/enterprise/articles/0502/01/news083_4.html