The statement under this script is not I write, forget where to see from, here to share to everyone, because in my understanding technology is used to share, I hope the original author see not mind.
1. Create a text to change the suffix name to. bat
2. Paste the bottom statement in, then save
@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 has found that the service is running and starts to stop
net stop MSSQLSERVER
Echo sc config MSSQLSERVER start = DISABLED Disable Service
) Else (
echo the service now handles the stop state and starts to start
Echo sc config MSSQLSERVER start = Manual Set service manual
net start MSSQLSERVER
)
Pause
Note that the ' MSSQLSERVER ' is the default instance name for SQL Server, and if you have more than one instance on your servers, you will need to manually replace the service name in the script.
Start the SQL Server service with bat