@echo offf
echo hello
@echo off
for /f "skip=3 tokens=4" %%i in ('sc query MongoDB') do set "zt=%%i" &goto :next
:next
echo "%zt%"
if "%zt%"=="RUNNING" (goto running)
if "%zt%"=="STOPPED" (goto stop)
if "%zt%"=="" (goto create)
:running
echo MongoDB服务在运行,是否要停止该服务,是请输入y,否请输入n
set /p option=please input:
if "%option%"=="y" (goto choiceY)
if "%option%"=="n" (goto choiceN)
goto :end
:stop
echo MongoDB服务现在处理停止状态,开始启动服务……
C:
cd \MongoDB\Server\3.2\bin
net start MongoDB
goto :end
:create
C:
cd \MongoDB\Server\3.2\bin
mongod -dbpath "C:\MongoDB\Server\3.2\data\db" -logpath "C:\MongoDB\Server\3.2\data\logs\MongoDB.log" -install -serviceName "MongoDB"
echo Made By danche
net start MongoDB
goto :end
:choiceY
echo MongoDB服务正在运行
:choiceN
C:
cd \MongoDB\Server\3.2\bin
net stop MongoDB
:end
pause