通过代码动态创建Windows服务
2020-01-15 06:37
113 查看
开发完Windows服务后,一般通过如下命令进行注册Windows服务
@echo off %SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\installutil.exe %~dp0\服务程序.exe pause
除了脚本的方式,通过代码,也可以注册Windows服务:
var ti = new TransactedInstaller(); ti.Installers.Add(new ServiceProcessInstaller { Account = ServiceAccount.LocalSystem }); ti.Installers.Add(new ServiceInstaller { DisplayName = displayName, ServiceName = serviceName, Description = description, //运行方式 StartType = ServiceStartMode.Automatic }); ti.Context = new InstallContext(); ti.Context.Parameters["assemblypath"] = 要安装的Windows服务实现dll或exe路径; ti.Install(new Hashtable());
转载于:https://www.cnblogs.com/liugh/p/8684734.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Android 通过Java代码生成创建界面。动态生成View,动态设置View属性。addRules详解
- C# 自动运行代码 (创建windows 服务的形式 )
- 用C++创建Windows服务代码
- android开发步步为营之102:通过xml设置或者代码动态设置windowSoftInputMode
- Android 通过Java代码生成创建界面。动态生成View,动态设置View属性。addRules详解
- C# 自动运行代码 (创建windows 服务的形式 )
- C#创建windows服务搭配定时器Timer使用实例(用代码做,截图版)
- 3D语音天气球(源码分享)——通过天气服务动态创建3D球
- ArcGIS Server代码动态创建发布服务(MapServer,ImageServer)
- 3D语音天气球(源码分享)——通过天气服务动态创建3D球
- ArcGIS Server代码动态创建发布服务(MapServer,ImageServer)
- Java 动态的创建注入代码,注入方法给类或者接口并通过反射调用
- 3D语音天气球(源码分享)——通过天气服务动态创建3D球
- C#创建windows服务搭配定时器Timer使用实例(用代码做,截图版)
- Android 通过Java代码生成创建界面。动态生成View,动态设置View属性。addRules详解
- C#创建windows服务搭配定时器Timer使用实例(用代码做,截图版)(从iteye搬到博客园)
- unity3d通过代码动态创建销毁游戏对象
- 把 Nginx 创建为 Windows 的一个服务
- Windows Azure Marketplace入门教学-通过代码操作DataMarket数据源
- 通过JS动态创建一个html DOM元素并显示