Commands for controlling services in Windows: Net and SC

Source: Internet
Author: User
Tags net command

A friend sent a question today, as shown below:

Create a batch file. The function is to stop a service, perform file sorting, and start the service.

The command used here is:

SC stop servicename

SC start servicename

A friend's problem is that when the system executes batch processing, the system will continue to execute batch processing without waiting for the service to stop. This will cause subsequent file operations to fail, subsequent restart operations will also fail.

I haven't used SC commands before, so I searched for the command usage on Google. There is no problem with my friend's usage.

First, some suspect that the service is special, but the probability of this situation is relatively small. After all, the service is managed by the Windows system.

So I used "Stop Service" as the keyword to re-search and found familiar commands: net stop and Net start. These two commands can also stop and start the service.

As a result, a new batch file is created in your computer and the net command is used to manipulate the service.

In this way, the system can wait and everything is normal to achieve the goal.

After the net is changed to SC, an error occurs. The system continues to execute batch processing without waiting for the service to stop.

Although these two commands are similar, there are still slight differences. If you do not pay attention to them directly, it will be contrary to the purpose.

Related Article

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.