@echo off
cd /d "%~dp0"
title JingPan C Drive Cleaner

set "PS=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe"
if not exist "%PS%" set "PS=powershell"

net session >nul 2>&1
if %errorlevel% neq 0 (
  echo Requesting administrator...
  "%PS%" -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  exit /b
)

"%PS%" -NoProfile -ExecutionPolicy Bypass -Command "Get-ChildItem -LiteralPath '%~dp0' -File -ErrorAction SilentlyContinue | Unblock-File -ErrorAction SilentlyContinue; Get-ChildItem -LiteralPath '%~dp0' | Unblock-File -ErrorAction SilentlyContinue"

:menu
cls
echo ========================================
echo   JingPan  C Drive Cleaner
echo ========================================
echo.
echo   1. Preview (no delete)
echo   2. Clean safe junk
echo   3. Find large files
echo   4. C drive usage
echo   5. Preview dev caches
echo   6. Disable hibernate
echo   7. Install weekly task
echo   0. Exit
echo.
set /p choice=Enter number: 

if "%choice%"=="1" goto preview
if "%choice%"=="2" goto clean
if "%choice%"=="3" goto large
if "%choice%"=="4" goto usage
if "%choice%"=="5" goto dev
if "%choice%"=="6" goto hibernate
if "%choice%"=="7" goto task
if "%choice%"=="0" exit /b 0
goto menu

:preview
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dp0Clean-CDrive.ps1"
goto end

:clean
echo.
echo Delete temp / update cache / recycle bin. Docs and apps stay.
set /p ok=Type Y then Enter: 
if /i not "%ok%"=="Y" goto menu
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dp0Clean-CDrive.ps1" -Execute
goto end

:large
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dp0Find-LargeFiles.ps1" -MinSizeMB 500
goto end

:usage
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dp0Get-CDriveUsage.ps1"
goto end

:dev
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dp0Clean-DevCaches.ps1"
goto end

:hibernate
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dp0Disable-Hibernate.ps1"
goto end

:task
"%PS%" -NoProfile -ExecutionPolicy Bypass -File "%~dp0Install-JingPanTask.ps1" -Hour 3 -Minute 30 -Interval weekly
goto end

:end
echo.
pause
goto menu
