Search code examples
c#.netpowercfg

How can run functions of powercfg by C# code?


how can run functions of powercfg by c# code?
for example I want to run this, for Set turn off the display: never

powercfg -CHANGE -monitor -timeout -ac 0 

Solution

  • Call it with Process.Start:

    Process.Start("powercfg", "-CHANGE -monitor -timeout -ac 0");