@echo off

IF "%1"=="/h" (
  echo syntax: %0 [/y] [/h]
  echo /y = continue without pausing for prompts
  goto :EOF
)

IF "%1"=="/y" (
  set SKIP=1
) ELSE (
  set SKIP=0
)

echo HP Smart Update Manager cached data delete script
echo                       -
echo Removing HP SUM cache files will require re-entering
echo all baseline locations, nodes and credentials.
echo                       -
echo This script should not be run while HP SUM is running.
echo                       -
IF %SKIP%==1 goto oktodelete
set /p ok="Are you sure you want to delete HP SUM cache files? [y or n] : "

if "%ok%"=="y" goto oktodelete
echo Exiting without deleting any files.
goto end


:oktodelete
IF EXIST %temp%\HPSUM (

  IF EXIST %temp%\HPSUM\baseline (
    echo Removing %temp%\HPSUM\baseline
    rmdir /s /Q %temp%\HPSUM\baseline
  ) ELSE (
    echo %temp%\HPSUM\baseline already deleted.
  )

  FOR %%F IN ( hpsum.pdb hpsum.pdb-wal hpsum.pdb-shm hpsum_remote.pdb ) DO (
    IF EXIST %temp%\HPSUM\%%F (
      echo Removing %temp%\HPSUM\%%F
      erase /Q %temp%\HPSUM\%%F
    ) ELSE (
      echo %temp%\HPSUM\%%F already deleted
    )
  )



) ELSE (
  echo No HP SUM temp directory found to delete. (%temp%\HPSUM)
)

:end
IF %SKIP%==0 (
  pause
)

