Get the App
SLTechnology News&Howtos  ›  Development  › 

How to start and stop services using batch processing

Shulou Source: shulou.com Published: 2022-06-03 08:37:41 10月04日 Update

This article shares with you about how to use batch processing to start and stop services. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Start or stop the service using the net.exe feature that comes with windows

The command line format for starting / stopping the service is: net start / stop service name (Note: the service should be set to manual startup type first)

Example:

Take starting and stopping the Oracle11g service as an example (ORCL is the database name):

The code is as follows:

Start the service of Oracle

@ echo. The service is started.

@ echo off

Net start OracleVssWriterORCL

Net start OracleDBConsoleorcl

Net start OracleOraDb11g_home1TNSListener

Net start OracleServiceORCL

@ echo. Activation complete!

@ pause

Stop the service of Oracle

The code is as follows:

@ echo. The service is stopping.

@ echo off

Net stop OracleVssWriterORCL

Net stop OracleDBConsoleorcl

Net stop OracleOraDb11g_home1TNSListener

Net stop OracleServiceORCL

@ echo. The service has stopped!

@ pause

Startup method:

Method 1. After saving, you can start or shut down the service directly by double-clicking the file.

Method 2. Set environment variabl

In the system variable in the environment variable, add the path to the batch file after PATH, don't forget to use the semicolon; separate it from the previous environment variable, and then enter the executable file directly in the start menu (the function of the environment variable is to tell the system where to enter information while it is running)

Thank you for reading! This is the end of this article on "how to use batch processing to start and stop services". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!

Tags: Services variables environment files methods code content more articles systems input running good practical location functions examples information semicolons functions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Apple Docker macOS