使用 windows bat 指令碼命令 一鍵啟動MySQL服務

2020-10-22 12:00:35

 

@echo off
rem Copyright (c) 2019 Moses and/or its affiliates.
rem Get Administrator Rights
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
rem start
net start MySQL56

注:複製下來儲存為.bat即可,如亂碼,另存為ANSI格式即可