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.
)
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 `