SC Command---Install, open, configure, and close Windows Service Bat batch (reprint)

Source: Internet
Author: User

Reprint: http://www.jb51.net/article/49627.htm

Reprint: http://blog.csdn.net/c1520006273/article/details/50539057

First, the direct use of CMD to service some of the operation

1. Installation Services

SC create test3 binpath= "C:\Users\Administrator\Desktop\win32srvDemo\win32srvdemo\Debug\win32srvDemo.exe"

Where: Test3 is the name of the service created, and BinPath is followed by the path where the exe file is run

2. Configuration Service

There are the following centralization methods:

sc config service name Start=auto (automatic)

sc config service name start= DEMAND (manual)

sc config service name start= DISABLED (disabled)

For example, the following command will start automatically on the XP system:

sc config test3 start= AUTO

3. Open Service

SC start test3  


4. Close the service

sc stop Test3

5. Delete Service

SC Delete Test3  

Second, for the convenience of use, can be edited as a bat batch file

(Create a new TXT file, name it yourself, and change the suffix to. bat file)

1. Create, configure, and open services

@echo. Service start ... @echo off@sc create test3 binpath= "C:\Users\Administrator\Desktop\win32srvdemo\win32srvdemo\Debug\ Win32srvdemo.exe "@net start test3@sc config test3 start= auto@echo off@echo. @pause


2. Close the service

@echo. Service shutdown @echo off@net stop Test3@echo Off@echo. Close the end! @pause


3. Delete Service

@echo. Service Delete @echo OFF@SC delete test3@echo off@echo. Delete End! @pause


Note:






REM indicates that the word identifier after this command is interpreted as a line (note), not executed, but for future reference (equivalent to comments in the program).

SC Command---Install, open, configure, and close Windows Service Bat batch (reprint)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.