Why does powercfg not do what I want in Windows 7?
July 1, 2011 2:08 AM Subscribe
How can I disable the keyboard Sleep key from a cmd script in Windows 7?
posted by flabdablet to Computers & Internet (4 answers total)
If I visit the Control Panel, then choose "Hardware and Sound", then choose "Change what the power buttons do", then change "When I press the sleep button:" to "Do nothing", then pressing the Sleep button on the keyboard does indeed do nothing. I can turn it back on by changing "When I press the sleep button:" back to "Sleep". So I'm sure that the physical button I'm playing with is indeed the one that Windows knows as the "sleep button", and I'm looking for a way to script that setting to avoid shenanigans in our school computer lab.
At present I'm doing this:
for /f "tokens=2 delims=:" %%G in ('powercfg -getactivescheme') do set guid=%%G
for /f %%G in ("%guid%") do set guid=%%G
powercfg -SetAcValueIndex %guid% SUB_BUTTONS SBUTTONACTION 0
And although this causes identical
to what I get by making the same change using the GUI, it does not actually affect the sleep button, which continues to sleep the PC when pressed.
What do I need to do to make Windows pay attention to settings applied via powercfg?