Reputation: 61596
I'd like to change Screen & Sleep time to Never
from code. I'm seeing code that prevents the Screen Saver from executing, but don't see anything for Screen & Sleep timers.
Is this possible?
Upvotes: 6
Views: 2231
Reputation: 19641
The easiest way would be to use the Powercfg utility.
Here are some useful options (xx = minutes):
monitor-timeout-ac xx
.monitor-timeout-dc xx
.standby-timeout-ac xx
.standby-timeout-dc xx
.hibernate-timeout-ac xx
.hibernate-timeout-dc xx
.Full example:
// Set the monitor timout to "never".
var info = new ProcessStartInfo("cmd", "/C powercfg /change -monitor-timeout-ac 0");
info.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(info);
Alternatively, you may use WMI to achieve the same goal. Here are some related posts:
Upvotes: 8