Search code examples
c#windows-10settingsdisplaysleep-mode

How to permanently change Windows 10 display setting using Registry or Commands?


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


Solution

  • 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