@if "%_echo%" == "" echo off

setlocal

REM set up the parameters
echo **** Retrieving parameters
call Setup.cmd

REM Create events directory (if not present) and delete any existing event files in it
if not exist "%BaseDirectoryPath%\Test\Events" md "%BaseDirectoryPath%\Test\Events"
del "%BaseDirectoryPath%\Test\Events" /q

REM Create notifications directory (if not present) and delete any existing notification files in it
if not exist "%BaseDirectoryPath%\Test\Notifications" md "%BaseDirectoryPath%\Test\Notifications"
del "%BaseDirectoryPath%\Test\Notifications" /q

echo.
echo **** Ensure instance is stopped before deleting the database
net stop ns$%InstanceName%

echo.
echo **** Delete the app databases
call %NSControlPath%\NSControl.exe delete -force -name %InstanceName% -s %SqlServer%

:end
exit /B 0

:error
exit /B 1

