1

Is there a way to permanently change Windows 10 display setting using C# code. Changes that I have to do are as follows:

  1. sleep: Never 2. screenSaver: disable 3. HardDisk(Sleep) : Never

Sleep Setting Image

I have a media player setup, and once this player is installed, the setting should be reflected. Don't want temporary changes like while the program is running, it will prevent sleep mode or something like that.

I am using .Net 4.5 with visual studio 2015

mpx
  • 3,081
  • 2
  • 26
  • 56
tabby
  • 1,878
  • 1
  • 21
  • 39
  • 2
    *Programs* shouldn't change *Users* settings just for the convenience of the program. Why is preventing sleep *whilst your code is running* not the correct solution here? – Damien_The_Unbeliever Jan 22 '16 at 11:51
  • Maybe you can set these values in the registry, but i think this will require a restart to be active. – AntiHeadshot Jan 22 '16 at 11:52
  • yes thank you for your answer i know it should not change user setting but Display is just a Advertising LED @Damien_The_Unbeliever – tabby Jan 22 '16 at 11:54
  • Thank you @AntiHeadshot for your answer but can you please tell me something about it or some resources where i look at – tabby Jan 22 '16 at 11:56
  • http://stackoverflow.com/questions/241222/need-to-disable-the-screen-saver-screen-locking-in-windows-c-net just follow this link will be help you – KARAN Jan 22 '16 at 11:59
  • thank you @kap for you suggestion but its not what i looking for – tabby Jan 22 '16 at 12:00
  • Possible duplicate of [Disabling Screen Saver and Power Options in C#](http://stackoverflow.com/questions/2284601/disabling-screen-saver-and-power-options-in-c-sharp) – Pranav Negandhi Jan 22 '16 at 12:08

1 Answers1

5

Instead of using registry i found a solution to solve these issue using command prompt and the command are:

require Administrative permission

To disable sleep run using cmd

  • powercfg -x -standby-timeout-ac 0

For HardDisk (Sleep->Never)

  • powercfg -Change -disk-timeout-ac 0

For monitor

  • powercfg -Change -monitor-timeout-ac 0

Edit:

For how to execute cmd command in C# see Here

tabby
  • 1,878
  • 1
  • 21
  • 39