利用Windows批處理自動開啓和關閉服務

     內存越來越大,裝的程序也越來越多,平時工作時Myeclipse、PowerDesigner、Dreamweaver、Tomcat、Plsqldev開了一大堆!很多經常用,但又不是每次都用到的程序,如Oracle、Mysql、VMware,設置自啓動太浪費內存,設置爲手動有必須每次一個一個的找到分別啓動,很是麻煩!

     這個批處理(以VMware爲例)可以讓你動動鼠標即可以自動開啓和關閉服務!

 

@echo off

for /f "skip=3 tokens=4" %%i in ('sc query VMAuthdService') do set "zt=%%i" &goto :next 

:next 
if /i "%zt%"=="RUNNING" ( 
	goto stop
) else ( 
	goto start
) 
pause 


:stop
	set /p input=the VMware service is running now ,do you want to stop it? (y or other for yes,n for no,default for y):
	if /i "%input%" == "n" (
		goto :eof
	)
net stop "VMware Authorization Service"
net stop "VMware DHCP Service"
net stop "VMware NAT Service"
net stop "VMware Virtual Mount Manager Extended"
pause
goto :eof

:start
	set /p input=the VMware service is stoped now ,do you want to start it? (y or other for yes,n for no,default for y): 
	if /i "%input%" == "n" (
		goto :eof
	)
net start "VMware Authorization Service"
net start "VMware DHCP Service"
net start "VMware NAT Service"
net start "VMware Virtual Mount Manager Extended"
pause
goto :eof

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章