@echo off


setlocal enableextensions
if exist Pn\Config.cmd pushd . & goto cfg
if exist ..\Pn\Config.cmd pushd .. & goto cfg
goto :eof

:cfg
call Pn\Config.cmd
prompt -$g

if not exist %mysqldir%\data\%COMPUTERNAME%.pid goto startsvc
goto end

:stopsvc
net stop %my_svc%
%mysqldir%\bin\mysqld-nt --remove %my_svc%

:startsvc
%pl% conf(`%mysqldir%\my.ini`, `(port\s*=)\s*\d+`, `$1 %my_port%`);
%mysqldir%\bin\mysqld-nt --install %my_svc% --defaults-file="%CD%\%mysqldir%\my.ini"
net start %my_svc% || %pause%

:end
prompt
popd
