zoukankan      html  css  js  c++  java
  • SC命令---安装、开启、配置、关闭 cmd命令行和bat批处理操作windows服务

    一、cmd命令行---进行Windows服务操作

    1、安装服务

    sc create 服务名 binPath= "C:UsersAdministratorDesktopwin32srvDemowin32srvdemoDebugwin32srvDemo.exe"

    注:服务名:指创建的Windows服务名

           binPath:指Windows服务程序的路径

    2、配置服务

    sc config 服务名 start=AUTO

    注:start=AUTO  (自动)

          start=DEMAND (手动)

          start=DISABLED  (禁用)

    3、开启服务

    net start 服务名

    4、关闭服务

    net stop 服务名

    5、删除服务

    sc delete 服务名

    二、第一种:bat批处理---进行Windows服务操作

    (新建一个txt文件,把后缀改成.bat文件)image

    1、创建、配置、开启服务

    复制代码
    @echo.服务启动......  
    @echo off  
    @sc create 服务名 binPath= "C:UsersAdministratorDesktopwin32srvdemowin32srvdemoDebugwin32srvdemo.exe"  
    @net start 服务名  
    @sc config 服务名 start= AUTO  
    @echo off  
    @echo.启动完毕!  
    @pause
    复制代码

    2、关闭服务

    复制代码
    @echo.服务关闭  
    @echo off  
    @net stop 服务名  
    @echo off  
    @echo.关闭结束!  
    @pause
    复制代码

    3、删除服务(删除前要关闭服务)

    复制代码
    @echo.服务删除  
    @echo off  
    @sc delete 服务名 
    @echo off  
    @echo.删除结束!  
    @pause
    复制代码

    二、第二种:bat批处理---进行Windows服务操作

    1、安装脚本Install.bat

    %SystemRoot%Microsoft.NETFrameworkv4.0.30319installutil.exe "E:wwwrootkjsmttwwwrootKJLMManagerShareOutBonusKJLMManagerShareOutBonus.exe"
    Net Start 服务名
    sc config 服务名 start= auto
    pause

    注:第一行:Window服务执行程序的路径

         第二行:启动服务

         第三行:设置服务自动运行

         最后一行:暂停,可以查看运行信息

    2、卸载脚本Uninstall.bat

    %SystemRoot%Microsoft.NETFrameworkv4.0.30319installutil.exe /u "E:wwwrootkjsmttwwwrootKJLMManagerShareOutBonusKJLMManagerShareOutBonus.exe"
    pause

    以上两种.bat 有的系统行有的不行,还不知道为什么。有懂得大神麻烦留言,谢谢。

    三、SC命令

    网友博客:http://blog.csdn.net/ddjj_1980/article/details/7493045

    转载:http://blog.csdn.net/moruna/article/details/9190733

  • 相关阅读:
    使用 Dockerfile 自定义 Nginx 镜像
    Windows下Rancher复制Pod内文件到本地
    SSL基础知识及Nginx/Tomcat配置SSL
    linux内核源码
    strace:跟踪进程的系统调用 、ltrace:跟踪进程调用库函数,runlevel & init & service
    C10K,C10M问题
    操作系统
    深入理解GOT表和PLT表
    为什么 List<Struct> 在 C# 中的分配速度比 List<Class> 快 15 倍
    如何计算时间复杂度
  • 原文地址:https://www.cnblogs.com/zmdblogs/p/12771984.html
Copyright © 2011-2022 走看看