Home > Database > Mysql Tutorial > body text

sqlServer手动启动服务Bat

WBOY
Release: 2016-06-07 15:40:37
Original
1485 people have browsed it

@echo off for /f "skip=3 tokens=4" %%i in ('sc query MSSQLSERVER') do set "zt=%%i" goto :next :next if /i "%zt%"=="RUNNING" ( echo 已经发现该服务在运行,开始停止 net stop MSSQLSERVER echo sc config MSSQLSERVER start = DISABLED 禁用服务 ) e

@echo off
for /f "skip=3 tokens=4" %%i in ('sc query MSSQLSERVER') do set "zt=%%i" &goto :next

:next
if /i "%zt%"=="RUNNING" (
 echo 已经发现该服务在运行,开始停止
 net stop  MSSQLSERVER
 echo sc config MSSQLSERVER start = DISABLED 禁用服务
) else (
 echo 该服务现在处理停止状态,开始启动
 echo sc config MSSQLSERVER start = Manual 设置服务手动
 net start MSSQLSERVER
)

pause

 

要说明的几点:

1、把以上的代码拷到记事本中,把后缀名改为bat。

2、'sc query MSSQLSERVER' 这句中的MSSQLSERVER,是你的SQL的服务的名字,

 

如果你不确定你的sql的服务名,你还可以做这样的一个测试,打开cmd,用命令:net stop MSQQLSERVER,如果能正常关闭sql的话,就说明你的服务名字是MSSQLSERVER。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template