echo off
REM First paramter is currently database version
echo Database version: %1
REM Program name to search 
set programName='Private server'
REM Setup file
set setupName=VetWebApi.exe
REM search already previousInstall
wmic product where "name like %programName%" get IdentifyingNumber, name, version > previousInstall
set hec=< previousInstall
set "batchdir=%~dp0"
echo "Loading"
find /c "Private server" previousInstall
	if %errorlevel% equ 1 goto notfound
	"%batchdir%%setupName%" /s ALLUSERS=True /l="%batchdir%logfile.txt" 
	if %errorlevel% equ 0 goto succes
	echo %errorlevel%
	goto done
	:succes
	Rem if install is success
		echo Install of private server was successful
		goto done
	:notfound
	Rem If install not found then run setup
		echo Previous install not found
		"%batchdir%%setupName%"
		goto done
	:done
	Rem clean up not necessary files
	del /f "%batchdir%previousInstall"
	