I'm trying to create a power plan managing Batch file that gives you the option to change power plan at a certain time of night/day. I only started coding this about 20 minutes ago so I apologize for the inconsistencies with capitalisation etc.
It should give the option to not to change the plan, which it does. However, when I run it, I find that the powerplan is not changed. I put the pauses and the Echos for Day and Night to give me an idea of what was going wrong and I was given the echos and pauses, but they seemed to be ignoring the goto commands at the end of each Powercfg.exe /Getactivescheme Line. It just goes onto the next line, until it hits the :no and exits.
Code: Select all
@echo off
SET /P ANSWER=Would you like to change Power Plan Now?
Echo You Chose: %ANSWER%
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={n} (goto :no)
goto :no
:yes
Echo You chose Yes!
if /i {%powercfg.exe /GETACTIVESCHEME%}=={Power Scheme GUID: 4c99af8d-43ab-4fff-b305-0aa164740418 (Daytime)} (goto :night)
Echo Daytime
pause
if /i {%powercfg.exe /GETACTIVESCHEME%}=={Power Scheme GUID: 83fb7ed3-151e-4578-9390-668114991c44 (Night)} (goto :day)
Echo Night
Pause
:no
echo You Pressed No!
Pause
Exit /b 0
:night
powercfg.exe /setactive 4c99af8d-43ab-4fff-b305-0aa164740418
pause
Exit /b 0
:day
powercfg.exe /setactive 83fb7ed3-151e-4578-9390-668114991c44
pause
Exit /b 0
Can anyone see any obvious flaws in this (despite the lack of a time check to change the plan, which I was going to put in after I had checked it all worked so far).