天天看點

bat腳本 手動啟動系統服務

需求:随着安裝軟體越來越多,計算機背景自啟動服務數量也越來越龐大。但是有些服務并不一定需要實時運作。

背景:需要将系統非必需的服務設定為 手動 啟動。

<span style="font-family:Verdana;">@echo off
title stop/start windows service
:allStart
cls
echo [1]	MySQL
echo [2]	Apache
echo [3]	Windows Update
echo [4]	Oracle
echo [5]	VMWare
echo [e]	exit
set in=
set /p in=please enter the num:

if "%in%"=="1" goto mysql
if "%in%"=="2" goto apache
if "%in%"=="3" goto windowsUpdate
if "%in%"=="4" goto Oracle
if "%in%"=="5" goto Vmware
if "%in%"=="e" goto allClose

:mysql
cls
echo [1]	start mysql service
echo [2]	stop mysql service
echo [b]	go back
echo [e]	exit
set in=
set /p in=	please enter the num:
if "%in%"=="1" goto mysqlStart
if "%in%"=="2" goto mysqlStop
if "%in%"=="b" goto allStart
if "%in%"=="e" goto allClose

:apache
cls
echo [1]	start apache service
echo [2]	stop apache service
echo [b]	go back
echo [e]	exit
set in=
set /p in=	please enter the num:
if "%in%"=="1" goto apacheStart
if "%in%"=="2" goto apacheStop
if "%in%"=="b" goto allStart
if "%in%"=="e" goto allClose

:windowsUpdate
cls
echo [1]	start windows update service
echo [2]	stop windows update service
echo [b]	go back
echo [e]	exit
set in=
set /p in=	please enter the num:
if "%in%"=="1" goto windowsUpdateStart
if "%in%"=="2" goto windowsUpdateStop
if "%in%"=="b" goto allStart
if "%in%"=="e" goto allClose

:Oracle
cls
echo [1]	start oralce service
echo [2]	stop oracle service
echo [b]	go back
echo [e]	exit
set in=
set /p in=	please enter the num:
if "%in%"=="1" goto oracleStart
if "%in%"=="2" goto oracleStop
if "%in%"=="b" goto allStart
if "%in%"=="e" goto allClose

:Vmware
cls
echo [1]	start VMware service
echo [2]	stop VMware service
echo [b]	go back
echo [e]	exit
set in=
set /p in=	please enter the num:
if "%in%"=="1" goto VmwareStart
if "%in%"=="2" goto VmwareStop
if "%in%"=="b" goto allStart
if "%in%"=="e" goto allClose

:mysqlStart
net start MySQL
goto allStart
:mysqlStop
net stop MySQL
goto allStart

:apacheStart
net start Apache2.2
goto allStart
:apacheStop
net stop Apache2.2
goto allStart

:windowsUpdateStart
net start wuauserv
goto allStart
:windowsUpdateStop
net stop wuauserv
goto allStart

:oracleStart
net start OracleOraDb11g_home1TNSListener
net start OracleServiceORCL
net start OracleDBConsoleorcl
goto allStart
:oracleStop
net stop OracleOraDb11g_home1TNSListener
net stop OracleServiceORCL
net stop OracleDBConsoleorcl
goto allStart

:VmwareStart
net start VMAuthdService
net start VMnetDHCP
net start "VMware NAT Service"
net start VMUSBArbService
net start VMwareHostd

goto allStart
:VmwareStop
net stop VMAuthdService
net stop VMnetDHCP
net stop "VMware NAT Service"
net stop VMUSBArbService
net stop VMwareHostd
goto allStart

:allClose
echo please enter any key to exit
pause
exit

rem ## how to delete the service in the windows?
rem ## sc delete [service name]
rem ## windows+R --> cmd --> services.msc</span>


           

繼續閱讀