zoukankan      html  css  js  c++  java
  • 批处理启动和停止VMware、Apache、MySQL、MSSQL、andLinux服务

    最近我们正在用Apache + MySQL +PHP + PHPMyAdmin + eclipse +Zend Optimizer+ Dreamweaver 在 Windows 下做一个PHP开发。因为Apache、MySQL、MSSQL、andLinux的服务默认都是随着电脑的启动而启动的,在不用的时候白占资源,所以昨天高手给我一个批处理程序来实现这些服务的启动和关闭。经过琢磨后,因为VMware有4个服务也有同样的情况,所以就将这个功能进行了扩展来实现上述所有服务的启动与关闭。现将源代码公布如下:(写完后保存为.cmd)

        @echo off
    set split=+-----------------------+
    :main
    cls
    echo What do you want?
    echo     %split%
    echo     ^|         list:         ^|
    echo     %split%
    echo     ^| [1] Start Services   ^|
    echo     ^| [2] Stop Services    ^|
    echo     %split%
    echo     ^| [E] EXIT             ^|
    echo     %split%

    set Choice=
    set /P Choice=Your Choice:
    echo ----------------------------------
    if /I "%Choice%"=="" goto main
    if /I "%Choice%"=="1" goto start
    if /I "%Choice%"=="2" goto stop
    if /I "%Choice%"=="E" goto exit
    goto main

    :start
    cls
    echo Which service do you want to start?
    echo     %split%
    echo     ^|                      list:                    ^|
    echo     %split%
    echo     ^|     [1] Apache2.2                             ^|
    echo     ^|     [2] MySQL                                 ^|
    echo     ^|     [3] andLinux                              ^|
    echo     ^|     [4] MSSQL                                 ^|
    echo     ^|     [5] VMware Authorization Service          ^|
    echo     ^|     [6] VMware DHCP Service                   ^|
    echo     ^|     [7] VMware Virtual Mount Manager Extended ^|
    echo     ^|     [8] VMware NAT Service                    ^|
    echo     %split%
    echo     ^|     [Q] QUIT                                  ^|
    echo     %split%
    set Choice=
    set /P Choice=Your Choice:
    echo ----------------------------------
    if /I "%Choice%"=="" goto start
    if /I "%Choice%"=="1" goto sta1
    if /I "%Choice%"=="2" goto sta2
    if /I "%Choice%"=="3" goto sta3
    if /I "%Choice%"=="4" goto sta4
    if /I "%Choice%"=="5" goto sta5
    if /I "%Choice%"=="6" goto sta6
    if /I "%Choice%"=="7" goto sta7
    if /I "%Choice%"=="8" goto sta8
    if /I "%Choice%"=="Q" goto main
    goto start

    :sta1
    net start Apache2.2
    echo Apache has started.
    goto ask

    :sta2
    net start MySQL
    echo MySQL has started.
    goto ask

    :sta3
    net start andLinux
    echo andLinux has started.
    goto ask

    :sta4
    net start MSSQLSERVER
    echo MSSQLSERVER has started.
    goto ask

    :sta5
    net start "VMware Authorization Service"
    echo VMware Authorization Service has started.
    goto ask

    :sta6
    net start "VMware DHCP Service"
    echo VMware DHCP Service has started.
    goto ask

    :sta7
    net start "VMware Virtual Mount Manager Extended"
    echo VMware Virtual Mount Manager Extended has started.
    goto ask

    :sta8
    net start "VMware NAT Service"
    echo VMware NAT Service has started.
    goto ask

    :stop
    cls
    echo Which service do you want to stop?
    echo     %split%
    echo     ^|                      list:                    ^|
    echo     %split%
    echo     ^|     [1] Apache2.2                             ^|
    echo     ^|     [2] MySQL                                 ^|
    echo     ^|     [3] andLinux                              ^|
    echo     ^|     [4] MSSQL                                 ^|
    echo     ^|     [5] VMware Authorization Service          ^|
    echo     ^|     [6] VMware DHCP Service                   ^|
    echo     ^|     [7] VMware Virtual Mount Manager Extended ^|
    echo     ^|     [8] VMware NAT Service                    ^|
    echo     %split%
    echo     ^|     [Q] QUIT                                  ^|
    echo     %split%
    set Choice=
    set /P Choice=Your Choice:
    echo ----------------------------------
    if /I "%Choice%"=="" goto stop
    if /I "%Choice%"=="1" goto sto1
    if /I "%Choice%"=="2" goto sto2
    if /I "%Choice%"=="3" goto sto3
    if /I "%Choice%"=="4" goto sto4
    if /I "%Choice%"=="5" goto sto5
    if /I "%Choice%"=="6" goto sto6
    if /I "%Choice%"=="7" goto sto7
    if /I "%Choice%"=="8" goto sto8
    if /I "%Choice%"=="Q" goto main
    goto stop

    :sto1
    net stop Apache2.2
    echo Apache has stoped.
    goto ask

    :sto2
    net stop MySQL
    echo MySQL has stoped.
    goto ask

    :sto3
    net stop andLinux
    echo andLinux has stoped.

    :sto4
    net stop MSSQLSERVER
    echo MSSQLSERVER has stoped.
    goto ask

    :sto5
    net stop "VMware Authorization Service"
    echo VMware Authorization Service has stoped.
    goto ask

    :sto6
    net stop "VMware DHCP Service"
    echo VMware DHCP Service has stoped.
    goto ask

    :sto7
    net stop "VMware Virtual Mount Manager Extended"
    echo VMware Virtual Mount Manager Extended has stoped.
    goto ask

    :sto8
    net stop "VMware NAT Service"
    echo VMware NAT Service has stoped.
    goto ask
    :ask
    echo ----------------------------------
    set Choice=
    set /P Choice=Start Others?(y/n)
    if "%Choice%"=="y" goto main

    :exit
    exit

  • 相关阅读:
    html 一号店静态页面
    多线程
    TCP通信
    MySQL连接查询
    Mysql数据库 DDL 数据定义语言
    MySQL数据库 DML 数据操作语言
    java字符流
    java File类
    java变量
    JDK、JRE、JVM的关系
  • 原文地址:https://www.cnblogs.com/chengulv/p/1491580.html
Copyright © 2011-2022 走看看