注意事项:

1. 添加调试代码

入口:

服务:

2. 再服务界面右键添加安装程序

3. 修改安装程序属性(Account)

4. 修改服务安装属性(DelayedAutoStart,ServiceName,StartType)

5. Release编译

6. 使用批处理脚本安装/卸载服务, 放在工程中, 属性->始终复制

安装

@echo off
path %path%;%windir%\Microsoft.NET\Framework\v4.0.30319
@echo on
@echo 请按任意键开始安装服务程序...
@pause
@echo 正在清理原有服务程序...
InstallUtil WindowsServiceThreadTest.exe /U > InstallService.log
@echo 清理完毕,正在开始安装服务程序...
InstallUtil WindowsServiceThreadTest.exe >> InstallService.log
@echo 服务安装完毕,请在 InstallService.log 中查看具体的操作结果。
@echo.
@pause

卸载

path %path%;%windir%\Microsoft.NET\Framework\v4.0.30319
@echo 请按任意键开始卸载服务程序...
@echo .
@pause
@echo 正在清理原有服务程序...
InstallUtil WindowsServiceThreadTest.exe /U > InstallService.log
@echo .
@echo 清理完毕,请在 InstallService.log 中查看具体的操作结果。
@pause

简单实例:

http://yunpan.cn/Q74jyjpKDdSnT (提取码:f217)

C#的简单的Windows Service 创建与安装的更多相关文章

  1. windows service创建使用整合

    C#创建Windows Service(Windows 服务)基础教程 C#winform windows服务程序创建与安装 C#实现WinForm随WINDOWS服务一起启动

  2. C#Windows Service服务程序的安装/卸载、启动/停止 桌面客户端管理程序设计

    C#Windows Service服务程序的安装/卸载.启动/停止 桌面客户端管理程序设计 关于Windows Service程序的安装与卸载如果每次使用命令行操作,那简直要奔溃了,太麻烦而且还容易出 ...

  3. Windows服务创建及安装

    Windows服务创建及安装http://www.cnblogs.com/tuyile006/archive/2006/11/27/573654.html

  4. windows service 2008 R2 安装net4.6环境失败,windows service 2008 R2 升级sp1问题

    一.错误 1.因为我的程序是以vs2017开发的,在windows service 2008 R2  IIS部署项目文件报出错误,因此要安装net4.6的环境. 2.windows service 2 ...

  5. 使用Windows service创建一个简单的定时器

    一.需求 我们有时候可能会想要做一些定时任务,例如每隔一段时间去访问某个网站,或者下载一些东西到我们服务器上等等之类的事情,这时候windows service 是一个不错的选择. 二.实现 1.打开 ...

  6. windows Service 创建部署

    Windows Service简介: 一个Windows服务程序是在Windows操作系统下能完成特定功能的可执行的应用程序.Windows服务程序虽然是可执行的,但是它不像一般的可执行文件通过双击就 ...

  7. Windows Service 学习系列(一):建立简单的Windows service

    参考:https://www.cnblogs.com/cncc/p/7170951.html 一.开发环境 操作系统:Windows 7 X64 开发环境:VS2017 编程语言:C# .NET版本: ...

  8. .net windows 服务创建、安装、卸载和调试

    原文:http://blog.csdn.net/angle860123/article/details/17375895 windows服务应用程序是一种长期运行在操作系统后台的程序,它对于服务器环境 ...

  9. Windows 服务 创建 和 安装 -摘自网络

    What a Windows Service is Enables you to create long-running executable applications that run in the ...

随机推荐

  1. c3p0xml配置详解

    <?xml version="1.0" encoding="UTF-8"?> <c3p0-config> <default-con ...

  2. 进阶笔记(1)——JavaScript 语言精碎

    调用:(调用一个函数将暂停当前函数的执行,传递控制权和参数给新函数) 每个函数接受连个附加参数:this (取决于调用的模式).argument. js的四种调用模式及this指向: 1.方法调用:( ...

  3. poj3581Sequence(后缀数组)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Sequence Time Limit: 5000MS   Memory Limi ...

  4. BestCoder Round #20 部分题解(A,B,C)(hdu5123,5124,5125)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud who is the best? Time Limit: 2000/1000 MS ...

  5. http://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p01_testing_output_sent_to_stdout.html

    http://python3-cookbook.readthedocs.io/zh_CN/latest/c14/p01_testing_output_sent_to_stdout.html draw. ...

  6. python多线程抓取网页信息

    #!/usr/env  python #-*- coding: utf-8  -*- import urllib  import urllib2  import random  import requ ...

  7. 【solr专题之一】Solr快速入门

    一.Solr学习相关资料 1.官方材料 (1)快速入门:http://lucene.apache.org/solr/4_9_0/tutorial.html,以自带的example项目快速介绍发Solr ...

  8. [C++程序设计]用指针变量作函数参数接收数组地址

    #include <iostream> using namespace std; void select_sort(int *p, int n) { int i, j, k; ; i &l ...

  9. deepin软件中心打不开

    想体验下deepin新特性,就修改了软件源为test版本,结果就坑了,软件中心打不开了...无奈之下,看了下论坛,找到了官方源地址,然后替换. sudo gedit /etc/apt/sources. ...

  10. Meteor Shower(POJ 3669)

    Meteor Shower Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12816   Accepted: 3451 De ...