first-time poster here. I'm trying to make a quick script to switch between power-saving and high-performance power modes based on if my laptop is plugged in. I did a bit of googling and came up with this, and so I tried to modify it to suit my needs. However, there seems to be an issue regarding the IF statement, I can't get it to run for some reason i can't understand. Running the checker function by itself works just fine. Happy for any help. Code included below. (For reference, if OnLine = true, then the device is plugged into mains)
@echo on
call :checker OnLine
if OnLine==true( powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c) else (powercfg /s e2ba9cbc-ad70-403c-8810-530a59af2d53)
pause
:checker
set OnLine=false
set cmd=WMIC /NameSpace:\\root\WMI Path BatteryStatus Get PowerOnline
%cmd% | find /i "true" > nul && set %~OnLine=true
echo %OnLine%
EXIT /B 0
Aucun commentaire:
Enregistrer un commentaire