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

本文介绍了一个用于自动开启和关闭VMware服务的批处理脚本。该脚本能够检查服务状态并根据用户选择启动或停止相关服务,极大地方便了日常使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值