1.安装

https://stackoverflow.com/questions/8164859/install-a-windows-service-using-a-windows-command-prompt

https://docs.microsoft.com/en-us/dotnet/framework/windows-services/how-to-install-and-uninstall-services

https://docs.microsoft.com/en-us/dotnet/framework/tools/installutil-exe-installer-tool

Navigate to the installutil.exe in your .net folder (for .net 4 it's C:\Windows\Microsoft.NET\Framework\v4.0.30319 for example) and use it to install your service, like this:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe"

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

C:\Windows\Microsoft.NET\Framework\v4.0.30319

这两个路径下的InstallUtil.exe都可以使用,如果项目使用的是AnyCPU进行编译

需要注意的是:必须使用管理员权限运行命令行工具。

Example

installutil /servicename="LFXSVC_FileExchange5.0_20170818" /displayname="FileExchange5.0_SourceCode"  /description="description of application" .\LISA.FileExchange.Service.exe

Remarks

需要注意的是,servicename不可以重复,并且displayname也不可以重复

2.移除,启动,停止

sc delete

C:\Windows\system32>sc delete LFXSVC_FileExchange5.0_20170831151735.535
[SC] DeleteService SUCCESS

sc start

sc stop

3.重命名Service

https://superuser.com/questions/975832/how-to-change-windows-service-name-after-creating-it

To change the display name of a service you can run:

sc config "Old service name" displayname= "New service name"

需要注意的是,config后面的参数是service name。这个必须通过服务的property才能看到,控制面板上显示的是DisplayName。

C:\Windows\system32>sc config LFXSVC_FileExchange5.0 DisplayName= "FileExchange5.0_Installer"

这个命令只在cmd中有效,在powershell中会遇到问题

PowerShell中的sc不是cmd中的,可以使用help sc查看

NAME
Set-Content

SYNTAX
Set-Content [-Path] <string[]> [-Value] <Object[]> [-PassThru] [-Filter <string>] [-Include <string[]>] [-Exclude <
string[]>] [-Force] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-NoNewline] [-Encoding <Fi
leSystemCmdletProviderEncoding> {Unknown | String | Unicode | Byte | BigEndianUnicode | UTF8 | UTF7 | UTF32 | Ascii
| Default | Oem | BigEndianUTF32}] [-Stream <string>] [<CommonParameters>]

Set-Content [-Value] <Object[]> -LiteralPath <string[]> [-PassThru] [-Filter <string>] [-Include <string[]>] [-Excl
ude <string[]>] [-Force] [-Credential <pscredential>] [-WhatIf] [-Confirm] [-UseTransaction] [-NoNewline] [-Encodin
g <FileSystemCmdletProviderEncoding> {Unknown | String | Unicode | Byte | BigEndianUnicode | UTF8 | UTF7 | UTF32 |
Ascii | Default | Oem | BigEndianUTF32}] [-Stream <string>] [<CommonParameters>]

ALIASES
sc

REMARKS
Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
-- To download and install Help files for the module that includes this cmdlet, use Update-Help.
-- To view the Help topic for this cmdlet online, type: "Get-Help Set-Content -Online" or
go to http://go.microsoft.com/fwlink/?LinkID=113392.

4.查询服务

http://www.cnblogs.com/chucklu/p/5847330.html    查看这篇文章里的1.5

http://www.cnblogs.com/chucklu/p/7248604.html

sc命令以及InstallUtil安装service的更多相关文章

  1. 使用SC命令操作(安装、开启、配置、关闭、删除)Windows下的服务

    目录 一.直接使用cmd命令行操作windows服务 二.使用bat批处理-操作windows服务 一.直接使用cmd命令行操作windows服务 1.安装服务 sc create 服务名 binPa ...

  2. [开发笔记]-使用bat命令来快速安装和卸载Service服务

    一般我们在编写完Service服务程序后,都是通过cmd命令提示窗口来安装或卸载服务,但频繁的在cmd窗口中去“拼”文件的路径着实让人“不能忍”.所以,我们需要一钟“更快捷”的方式来进行安装或者卸载操 ...

  3. SC命令---安装、开启、配置、关闭 cmd命令行和bat批处理操作windows服务

      一.cmd命令行---进行Windows服务操作 1.安装服务 sc create 服务名 binPath= "C:\Users\Administrator\Desktop\win32s ...

  4. 转载:使用bat命令来快速安装和卸载Service服务

    一般我们在编写完Service服务程序后,都是通过cmd命令提示窗口来安装或卸载服务,但频繁的在cmd窗口中去“拼”文件的路径着实让人“不能忍”.所以,我们需要一钟“更快捷”的方式来进行安装或者卸载操 ...

  5. (转)SC命令---安装、开启、配置、关闭windows服务 bat批处理

    本文转载自:http://blog.csdn.net/moruna/article/details/9190733 废话不多说,看命令行更直接! 一.直接使用cmd来进行服务的一些操作 1.安装服务 ...

  6. 使用SC命令时注意事项

    使用SC命令时注意事项[转] Windows 2003 Server存在一个sc命令,(好像Windows 2000/XP/NT都有这个.)该命令可以手工创建Windows服务(NT Service) ...

  7. cmd sc命令进行服务操作

    sc 命令可以注册.删除和查询系统服务 sc可供选择的参数有很多,这里不详细描述.只介绍简单的最基本的sc使用方式. 1. sc create 创建windows服务 eg: sc \\myserve ...

  8. C#通过SC命令和静态公共类来操作Windows服务

    调用的Windows服务应用程序网址:http://www.cnblogs.com/pingming/p/5115304.html 一.引用 二.公共静态类:可以单独放到类库里 using Syste ...

  9. 如何在本地数据中心安装Service Fabric for Windows集群

    概述 首先本文只是对官方文档(中文,英文)的一个提炼,详细的安装说明还请仔细阅读官方文档. 虽然Service Fabric的官方名称往往被加上Azure,但是实际上(估计很多人不知道)Service ...

随机推荐

  1. (WC2016模拟十一)【BZOJ4695】最假女选手

    ps:好久没更博啦……这几天连着有模拟赛,等初赛前后休息的时候来疯狂补坑吧……顺便补一下前面的数论啥的? 题解: mdzz我场上写了个15分暴力长度跟标算差不多... 线段树大法好啊!这题听说很多人做 ...

  2. IE模式下EasyUI Combobox无效问题

    近期开发过程中遇到IE浏览器Combobox无法正常加载问题. 经过一番百度说IE渲染过快导致页面渲染完了easyUI Combobox还没有加载.设置延迟加载后依旧无效. 后将input标签的Cla ...

  3. CSS常用样式--background

    CSS background 属性 参考:W3school- CSS background 所有浏览器都支持 background 属性,其简写形式,在一个声明中设置所有的背景属性,各属性需按顺序,语 ...

  4. Swift编写的一些完整的app

    收集了一些实用swift编写的app,这些demo都是不错的值得学习的. 知乎日报 Swift-ZhihuDaily Swift版知乎日报 参照了YANGReal的糗事百科和uitableview的例 ...

  5. 三角函数之美-水波纹载入LoadingView

    一.前言 学习是要总结的.近期几天学习了画图相关的,可是使用的机会较少,如今又快要遗忘了,这次看了水波纹的绘制.认为十分有意思,还是 把实现的方法记录下来.技术无他,为手熟尔.还是要多练习,空淡误国, ...

  6. HDU 2112 HDU Today &lt;SPFA算法+map函数&gt;

    HDU Today Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. kotlin官方文档-1.0入门

    什么是Kotlin?   图片发自简书App Kotlin是JetBrains开发的基于JVM的语言,JetBrains想必大家应该很熟悉了,他们创造了很多强大的IDE,android studio谷 ...

  8. Linux系统下安装redis

    Linux 下安装 下载地址:http://redis.io/download,下载最新文档版本. 本教程使用的最新文档版本为 2.8.17,下载并安装: $ wget http://download ...

  9. C#篇(一)——字段与属性

    字段和属性有什么区别? class Student { private int age; public int Age { get { return age; } set { age = value; ...

  10. hdu 2018 - 递推

    dp[i][1..4] 第i年时年龄为1234的牛的数目 */ #include <cstdio> #include <cstring> ; ]; int main(){ me ...