@echo off
setlocal enabledelayedexpansion
echo "Please enter the time to turn off the monitor, the unit is minutes, the default is 1 minute"
set /p "timeout="
if NOT DEFINED timeout (echo "The time you entered is 1 minute" && set "timeout=1" && goto set_monitor_timeout
)else ( rem Note the positional relationship between the else statement and brackets here
echo "The time you enter is %timeout% minutes"
)
:set_monitor_timeout
echo "The time you enter is %timeout% minutes"
echo "The current power management solution used by the system is:"
echo ==============================================
powercfg -list >c:\powercfg_mingli |@findstr "*" c:\powercfg_mingli
powercfg -x -monitor-timeout-ac %timeout%
echo ==============================================
del /f /s /q c:\powercfg_mingli
pause