@echo off
echo Welcome to EnTrak Un-Installer

SET location=NF
SET batpath=%cd%

IF EXIST "C:\Program Files (x86)" (
	chdir /D "C:\Program Files (x86)"
	IF EXIST Ampps (
		SET location=PFx86
	)
)
IF EXIST "C:/Program Files" (
	chdir /D "C:\Program Files"
	IF EXIST Ampps (
		SET location=PF
	)
)

rem cd %batpath%

IF %location% == NF (
	ECHO EnTrak install location is not found 
	ECHO uninstall failed
	ECHO please locate the EnTrak folder and
	ECHO associated bat files and delete manually
)

IF %location% == PFx86 (
	ECHO install to PFx86
	RD /S /Q C:\"Program Files (x86)"\Ampps\www\EnTrak\EnTrak
	DEL /Q  C:\"Program Files (x86)"\Ampps\export.bat
	DEL /Q  C:\"Program Files (x86)"\Ampps\FetchDataCronCallVBS.bat
	DEL /Q  C:\"Program Files (x86)"\Ampps\FetchDel.bat
	DEL /Q  C:\"Program Files (x86)"\Ampps\import.bat
	DEL /Q  C:\"Program Files (x86)"\Ampps\runES.bat
	copy /Y "C:\Program Files (x86)\Ampps\www\EnTrak\EnTrak\ProjectsList.csv" C:\tmp\PLU.csv
	IF NOT [%1]==[auto] RD /S /Q C:\"Program Files (x86)"\Ampps\www\EnTrak
)

IF %location% == PF (
	ECHO install to PF
	RD /S /Q C:\"Program Files"\Ampps\www\EnTrak\EnTrak
	DEL /Q  C:\"Program Files"\Ampps\export.bat
	DEL /Q  C:\"Program Files"\Ampps\FetchDataCronCallVBS.bat
	DEL /Q  C:\"Program Files"\Ampps\FetchDel.bat
	DEL /Q  C:\"Program Files"\Ampps\import.bat
	DEL /Q  C:\"Program Files"\Ampps\runES.bat
	copy /Y "C:\Program Files\Ampps\www\EnTrak\EnTrak\ProjectsList.csv" C:\tmp\PLU.csv
	IF NOT [%1]==[auto] RD /S /Q C:\"Program Files"\Ampps\www\EnTrak
)

rem ECHO batpath is %batpath%
rem ECHO current console location is %cd%
rem ECHO install location is %location%

IF NOT [%1]==[auto] SET/P userinput="uninstall complete... press return(enter) to exit"
rem TIMEOUT 30