darkGrimoire / hoyolab-daily-bot

Genshin Impact's Hoyolab Daily Check-in Bot
MIT License
115 stars 44 forks source link

Update uninstaller #22

Closed TrollSkyhero10 closed 1 year ago

TrollSkyhero10 commented 1 year ago

I asked chatgpt to improve the uninstaller by checking the config file, if it fails to delete it, the code will ask for the name to be entered manually. Small improvement hopefully it helps someone

` @echo off

:: Use PowerShell to read the SCHEDULER_NAME from config.json for /f %%i in ('powershell -command "(Get-Content -Raw -Path .\config.json | ConvertFrom-Json).SCHEDULER_NAME"') do set "task_name=%%i"

:: Prompt for task_name if not found in config.json if "%task_name%" == "" ( set /p task_name="Enter SCHEDULER_NAME: " )

:: Delete the scheduled task schtasks /Delete /F /TN "%task_name%"

:: Check the exit code of schtasks if %errorlevel% neq 0 ( echo Failed to delete task %task_name%. Please enter the correct task name: set /p task_name="Enter task name: " schtasks /Delete /F /TN "%task_name%" if %errorlevel% neq 0 ( echo Failed to delete task %task_name%. Exiting. ) else ( echo Task %task_name% deleted successfully. ) ) else ( echo Task %task_name% deleted successfully. )

pause `

TrollSkyhero10 commented 1 year ago

sorry didnt realise this was so old, I looked at latest update time and thought it was this year