论坛首页 综合技术论坛

利用Windows批处理自动开启和关闭服务

浏览 2842 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (7) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-11-12  

     内存越来越大,装的程序也越来越多,平时工作时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

 

论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics