CMD命令启动和关闭虚拟机VMware || Apache || svn

将这些bat批处理放到exe同名目录下,然后发送快捷方式到桌面,属性里面更改该bat图标时定位到该exe,需要时点图标运行即可。

224749_gKLV_1859834.png

VMware.bat:开启虚拟机并开启虚拟机服务、虚拟网卡,退出虚拟机后再运行该bat则可以关闭这些服务和虚拟网卡。

@echo off
::查找某个服务是否在运行,需要启动则全部启动
for /f "skip=3 tokens=4" %%i in ('sc query VMwareHostd') do set "zt=%%i"&goto doAction
:doAction
if /i "%zt%"=="STOPPED" goto open
if /i "%zt%"=="RUNNING" goto close
:open
::启用网络连接
netsh interface set interface name="VMware Network Adapter VMnet1" admin=ENABLED
netsh interface set interface name="VMware Network Adapter VMnet8" admin=ENABLED
::启动服务
net start VMAuthdService
net start VMnetDHCP
net start "VMware NAT Service"
net start VMUSBArbService
net start VMwareHostd
::启动主程序
start "" vmware.exe
goto myexit
:close
set /p all=强制结束退出?(Y/N):
if /i "%all%"=="n" goto myexit
::关闭服务
net stop VMwareHostd
net stop VMUSBArbService
net stop "VMware NAT Service"
net stop VMnetDHCP
net stop VMAuthdService
::关闭网络连接
netsh interface set interface name="VMware Network Adapter VMnet1" admin=DISABLED
netsh interface set interface name="VMware Network Adapter VMnet8" admin=DISABLED
::强杀进程
taskkill /F /im vmware.exe
taskkill /F /im vmware-tray.exe
goto myexit
:myexit
::设置服务为手动
sc config VMAuthdService start= demand
sc config VMnetDHCP start= demand
sc config "VMware NAT Service" start= demand
sc config VMUSBArbService start= demand
sc config VMwareHostd start= demand
exit(0)

其他的都是在这个bat上进行的扩展

TortoiseProc.bat:同时开启SVN服务和Apache,并打开TortoiseSVN Repository Browser

@echo off
for /f "skip=3 tokens=4" %%i in ('sc query svnserve') do set "zt=%%i"&goto doAction
:doAction
if /i "%zt%"=="STOPPED" goto open
if /i "%zt%"=="RUNNING" goto close
:open
net start svnserve
net start Apache2.2
### 这里复制时需要更改,因为TortoiseSVN和Apache不在同一目录
start "" "D:\Java\Apache\Apache2.2.25-x86\bin\ApacheMonitor.exe"
start "" TortoiseProc.exe /command:repobrowser
goto myexit
:close
set /p all="退出svn & apache?(Y/N):"
if /i "%all%"=="n" goto myexit
net stop svnserve
net stop Apache2.2
taskkill /F /im ApacheMonitor.exe
taskkill /F /im TortoiseProc.exe
goto myexit
:myexit
sc config svnserve start= demand
sc config Apache2.2 start= demand
exit(0)

MySQL Front:开启mysql可视化编辑器时同时启动mysql服务

@echo off
for /f "skip=3 tokens=4" %%i in ('sc query mysql5') do set "zt=%%i"&goto doAction
:doAction
if /i "%zt%"=="STOPPED" goto open
if /i "%zt%"=="RUNNING" goto myexit
:open
net start mysql5
:myexit
start "" MySQL-Front.exe
sc config mysql5 start= demand
exit(0)


转载于:https://my.oschina.net/ezce/blog/282543

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值