一、在Visual Studio中创建Windows服务
二、添加代码
三、回到Service1.cs设计视图中添加安装程序,设置serviceInsaller1组件的属性:ServiceName与StartType;设置serviceProcessInstaller1组件的属性Account=LocalSystem
四、生成项目,按F5会出现错误,但也会在bin/Debug下产生服务对应的exe程序。
五、将c:/windows/microsoft.net/Framework/v2.0.50727下的InstallUtil.exe拷贝到windows/system32下面
六、用installUtil “服务名称” 命令注册服务