none
How to invoke a powercfg command in c#?

    Question

  • Basically I'm trying to execute this simple  powercfg command in c#   "powercfg  -X  -monitor-timeout-ac 1".   I have used the Systen.diagnostic.process to no avail.  It doesn't seem to be taking the parameters.  Does anyone have any ideas as to the simplest way to pass on the parameters to the command??
    NR
    Monday, February 07, 2011 11:50 PM

Answers

  • I found the answer on another forum (stackoverflow),  I basically had the syntax incorrect in the process class.  The proper syntax is:

    System.Diagnostics.

     

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


    NR
    • Marked as answer by Highlander4 Tuesday, February 08, 2011 1:11 AM
    Tuesday, February 08, 2011 1:10 AM

All replies

  • I found the answer on another forum (stackoverflow),  I basically had the syntax incorrect in the process class.  The proper syntax is:

    System.Diagnostics.

     

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


    NR
    • Marked as answer by Highlander4 Tuesday, February 08, 2011 1:11 AM
    Tuesday, February 08, 2011 1:10 AM
  • I suggest you to use the Power Scheme Management APIs to change the policies in a power scheme. For more help in power management programming, try the Developing Applications with Power Management forum.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Tuesday, February 08, 2011 1:51 AM