@echo off setlocal EnableDelayedExpansion rem ---------------------------------------------- rem 設定 rem ---------------------------------------------- rem サービス名を設定 set apache=Apache2.4 set mysql=MariaDB10 rem XAMPPのバージョンを設定 set xamp_ver=%1 set xamp_link=xampp set xamp_target=%xamp_link%%xamp_ver% rem エラーチェック echo; if ""%xamp_ver%""=="""" ( echo 使い方: %0 [XAMPPのバージョン番号] echo 実行例: %0 1.2.3 goto END ) whoami /priv | find "SeLoadDriverPrivilege" > nul if !ERRORLEVEL! neq 0 ( echo Error: 管理者権限で実行して下さい goto END ) if not exist %xamp_target% ( echo Error: "%xamp_target%" が見つかりません goto END ) rem ---------------------------------------------- rem サービスの停止 rem ---------------------------------------------- if not ""%apache%""=="""" ( sc query "%apache%" | findstr STATE | findstr RUNNING > null if !ERRORLEVEL! equ 0 ( echo stop "%apache%" net stop "%apache%" ) ) if not ""%mysql%""=="""" ( sc query "%mysql%" | findstr STATE | findstr RUNNING > null if !ERRORLEVEL! equ 0 ( echo stop "%mysql%" net stop "%mysql%" ) ) rem ---------------------------------------------- rem XAMPPリンクの切り替え rem ---------------------------------------------- if exist %xamp_link% ( echo remove %xamp_link% rmdir %xamp_link% ) echo link %xamp_target% to %xamp_link% mklink /D %xamp_link% %xamp_target% echo; rem ---------------------------------------------- rem サービスの開始 rem ---------------------------------------------- if not ""%apache%""=="""" ( sc query "%apache%" | findstr STATE | findstr RUNNING > null if !ERRORLEVEL! neq 0 ( echo start "%apache%" net start "%apache%" ) ) if not ""%mysql%""=="""" ( sc query "%mysql%" | findstr STATE | findstr RUNNING > null if !ERRORLEVEL! neq 0 ( echo start "%mysql%" net start "%mysql%" ) ) goto END :END rem ---------------------------------------------- rem 現在のXAMPP情報の表示 rem ---------------------------------------------- echo; echo 【 現在のXAMPP情報 】 echo; dir %xamp_link%*|findstr "^[0-9]"