Use the net.exe function provided by windows to start or stop services
The command line format for starting/stopping a service is: net start/stop service name (note: the service must be set to manual start first)
Example:
Take starting and stopping the Oracle11g service as an example (ORCL is the database name ):
Copy codeThe Code is as follows: % start Oracle service %
@ Echo. Start the service ......
@ Echo off
Net start variable levsswriterorcl
Net start OracleDBConsoleorcl
Net start OracleOraDb11g_home1TNSListener
Net start OracleServiceORCL
@ Echo. started!
@ Pause
% Stop Oracle services %Copy codeThe 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 is stopped!
@ Pause
Start method:
Method 1. After saving the file, you can directly double-click the file to start or close the service.
Method 2. Set Environment Variables
In the system variables in the environment variables, add the PATH of the batch file after the PATH. Do not forget to use a semicolon; separate it from the previous environment variables, then, enter the executable file directly in the running of the Start menu (the environment variable is used to tell the system where information is entered during running)