使用Vs的 Windows Service模板可以很方便地开发Windows 服务。在Service文件 的设计界面,右键点击Add Installer,可以添加一个ProjectInstaller类, 然后设定服务的运行账号,名称等。

        #region Component Designer generated code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();// // serviceProcessInstaller1// this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService;this.serviceProcessInstaller1.Password = null;this.serviceProcessInstaller1.Username = null;// // serviceInstaller1// this.serviceInstaller1.Description = "Sample Service Description";this.serviceInstaller1.DisplayName = "Sample Service";this.serviceInstaller1.ServiceName = "SampleService";// // ProjectInstaller// this.Installers.AddRange(new System.Configuration.Install.Installer[] {this.serviceProcessInstaller1,this.serviceInstaller1});}#endregionprivate System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;private System.ServiceProcess.ServiceInstaller serviceInstaller1;

开发完毕后,可以使用.Net Framework自带的InstallUtil.exe安装服务。

installutil [/u[ninstall]] [options] assembly [[options] assembly] …

如果想在安装的时候指定服务名,或者想在同一台机器上安装多份服务,可以采用下面的方式:

         #region Component Designer generated code/// <summary>/// Required method for Designer support - do not modify/// the contents of this method with the code editor./// </summary>private void InitializeComponent(){components = new System.ComponentModel.Container();}#endregion

然后使用下面的命令安装:

sc create <servicename> binpath="<pathtobinaryexecutable>" [option1] [option2] [optionN]

Windows Service 创建与安装相关推荐

  1. Windows服务创建及安装

    Windows服务创建及安装 原文:Windows服务创建及安装 我们将研究如何创建一个作为Windows服务的应用程序.内容包含什么是Windows服务,如何创建.安装和调试它们.会用到System ...

  2. windows安装程序创建_如何在Windows上创建已安装程序的列表

    windows安装程序创建 Reinstalling Windows is a good way to fix serious problems with your computer, or just ...

  3. .net windows service开发与安装

    1.创建一个Windows Service项目名为WindowsServiceTest: 2.添加一个Windows Service项名为TestService.cs: 3.实现TestService ...

  4. Windows Service 2012 R2安装步骤

    本次实验是在虚机上面进行,虚机已经搭建成功(搭建地址为192.168.47.155的虚机),具体的windows service 2012 R2 的安装步骤如下: 点击下一步-现在安装-输入密钥-根据 ...

  5. (Windows)Anaconda创建虚拟环境安装tensorflow

    创建虚拟环境 首先打开Anaconda Prompt,创建虚拟环境 conda create -n tensorflow python=3.7 激活虚拟环境 激活虚拟环境tensorflow acti ...

  6. C# 创建Windows Service(Windows服务)程序

    工具: Visual Studio Community 2015 写在前面: Windows可以在后台做一些任务,今天分享下Windows Service创建.安装.调试的方法以及一些异常问题的处理 ...

  7. C#创建一个Windows Service

    Windows Service这一块并不复杂,但是注意事项太多了,网上资料也很凌乱,偶尔自己写也会丢三落四的.所以本文也就产生了,本文不会写复杂的东西,完全以基础应用的需求来写,所以不会对Window ...

  8. 【windows service】C# 创建Windows Service(Windows服务)程序

    C# 创建Windows Service(Windows服务)程序 很多年前大概08年做了一个windows桌面程序推送邮件给用户的程序,然后通过windows 计划任务每隔N分钟重复执行. 今天闲暇 ...

  9. 创建Windows Service

    基本参照使用C#创建Windows服务,添加了部分内容 目录 创建Windows Service 可视化管理Windows Service 调试 示例代码 创建Windows Service 选择C# ...

最新文章

  1. python描述符魔术方法_Python所有特殊方法、魔术方法、 钩子
  2. py提取文字中的时间_一次提取100个视频中的文案!节省时间有绝招在手视频文案提取...
  3. JavaScript event loop事件循环 macrotask与microtask
  4. md3600i存储服务器连接 iscsi+multipath配置
  5. 偶然搜索看到的杂谈——什麼東西是.NET程序員可以掌握並且可倚仗十年而不管微軟存在與否的技術呢?...
  6. ​我们为何需要更安全的系统编程语言?
  7. android中的回调简单认识
  8. android 多媒体相册,朵朵多媒体相册免费版
  9. 一提开发满脸泪,不如尬评来赢书 | 张开涛亲笔签名
  10. Mac上Fortran环境搭建
  11. Java读取图片 cmyk转rgb
  12. 差分传输中的tvs二极管阵列
  13. 当居住产业挺进深水区,数字化能衍生出什么机会?
  14. linux平台下的6818开发板(ARM)显示屏的字体显示
  15. 两个用于谷歌输入法的颜文字拓展
  16. Apache安装与基本配置
  17. Lecture 12: Iterated Expectations; Sum of a Random Number of Random Variables
  18. 数学的回忆(二)——麦克斯韦方程
  19. 嵌入式软件工程师必备技能
  20. 未来最有竞争力的编程语言_如何在2020年9月开始竞争性编程

热门文章

  1. 六种方法教你更好地使用小型WiFi摄像机
  2. 关于ADFS的局限性,你了解多少?
  3. Spring/SpringBoot学习中遇到的问题记录(2):java.lang.ClassNotFoundException:org.apache.jsp.WEB_002dINF.views.xx
  4. webview加载网页,tel协议不会调出拨号盘?该如何处理
  5. 普通文本el-tootip超出宽度自动显示省略号,悬停显示
  6. Mongodb 查询重复数据
  7. 美赛BOOM数学建模4-3马尔科夫预测
  8. vue大数据可视化【数字滚动效果】
  9. Python 将jpg批量转换为png
  10. python人机猜拳游戏代码_python 实现人和电脑猜拳的示例代码