批处理脚本:后台启动bat脚本与mysql启动

发布时间:2020-11-01编辑:脚本学堂
分享一例批处理脚本,用于后台程序的启动,这里以mysql的启动为例,有兴趣的朋友可以参考学习下。

本节内容:
mysql后台脚本的bat批处理脚本。

代码:
 

复制代码 代码示例:

@echo off

if "%1" == "stop" goto stop
if not "%1" == "start" (
   echo useage as %0 start/stop
   pause
   goto end
)
if "%2" == "background" goto background
 rem mshta vbscript:createobject("wscript.shell").run("%~nx0 %1 background",0)(window.close)&& exit
 mshta vbscript:createobject("wscript.shell").run("%~nx0 %1 background",0)(window.close)
  echo start over
 goto end
:background

if "%1" == "start" (
 goto start
) else if "%1" == "stop" (
 goto stop
)
echo "use as %1 start/stop"
pause
goto end
  
:start
mysqld
goto end

:stop
taskkill /F /IM mysqld.exe
pause

:end