zoukankan      html  css  js  c++  java
  • sc命令以及InstallUtil安装service

    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:WindowsMicrosoft.NETFrameworkv4.0.30319 for example) and use it to install your service, like this:

    "C:WindowsMicrosoft.NETFrameworkv4.0.30319installutil.exe" "c:myservice.exe"

    C:WindowsMicrosoft.NETFramework64v4.0.30319

    C:WindowsMicrosoft.NETFrameworkv4.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:Windowssystem32>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:Windowssystem32>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

  • 相关阅读:
    数据攻略●R语言自述
    测试实例
    xml反射
    过滤器
    使用s标签来进行简单的表格配置
    将Spring、Hibernate、Struts2连接起来
    Spring容器
    初见Spring框架
    Spring框架的AOP
    Hibernate里面的几个方法
  • 原文地址:https://www.cnblogs.com/chucklu/p/7150420.html
Copyright © 2011-2022 走看看