Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6666957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:52:59+00:00 2026-05-26T02:52:59+00:00

how can I turn off ‘allow hybrid sleep’ in advanced power setting? by c#

  • 0

how can I turn off ‘allow hybrid sleep’ in advanced power setting? by c#
by manually: power options -> change Plan Settings -> change advanced power setting->
Sleep-> ‘Allow hybrid sleep’ -> plugged in: OFF

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:52:59+00:00Added an answer on May 26, 2026 at 2:52 am

    If you are targeting Windows 7/2008 Server then you can use WMI and the Win32_PowerSetting class. Below is code that does that. Make sure to add an assembly reference and using directive to System.Management.

        private bool SetAllowHybridSleep(bool enabled)
        {
            //Machine to work on, "." for local
            string RemotePC = ".";
    
            //Set the namespace to the power namespace, used throughout the function
            ManagementScope ms = new ManagementScope(@"\\" + RemotePC + @"\root\cimv2\power");
    
            //Will hold each of our queries
            ObjectQuery oq = null;
    
            //Will hold the values of our power plan and the specific setting that we want to change
            Guid PowerPlanInstanceId = Guid.Empty;
            string PowerSettingInstanceId = null;
    
            //Look for the specific setting that we want
            oq = new ObjectQuery(string.Format("SELECT * FROM Win32_PowerSetting WHERE ElementName = 'Allow hybrid sleep'"));
            using (ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq))
            {
                ManagementObjectCollection results = mos.Get();
                foreach (ManagementObject obj in results)
                {
                    foreach (PropertyData p in obj.Properties)
                    {
                        if (p.Name == "InstanceID")
                        {
                            //This will give us a string with a GUID specific to our setting
                            PowerSettingInstanceId = p.Value.ToString();
                            break;
                        }
                    }
                }
            }
    
            //Sanity check
            if (string.IsNullOrEmpty(PowerSettingInstanceId))
            {
                Console.WriteLine("System does not support hybrid sleep");
                return false;
            }
    
            //Look for the active power scheme
            oq = new ObjectQuery("SELECT * FROM Win32_PowerPlan WHERE IsActive=True");
            using (ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq))
            {
                ManagementObjectCollection results = mos.Get();
                foreach (ManagementObject obj in results)
                {
                    foreach (PropertyData p in obj.Properties)
                    {
                        if (p.Name == "InstanceID")
                        {
                            //The instance contains a string with a GUID inside of it, use the code below to get the GUID by itself
                            if (!Guid.TryParse(System.Text.RegularExpressions.Regex.Match(p.Value.ToString(), @"\{[0-9a-f]{8}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{12}\}").Value, out PowerPlanInstanceId))
                            {
                                Console.WriteLine("Could not find active power plan");
                                return false;
                            }
                            break;
                        }
                    }
                }
            }
    
            //Now we need to update the actual power setting in the active plan
            //Get all power schemes for the target setting
            oq = new ObjectQuery(string.Format("ASSOCIATORS OF {{Win32_PowerSetting.InstanceID=\"{0}\"}} WHERE ResultClass = Win32_PowerSettingDataIndex", PowerSettingInstanceId.Replace(@"\", @"\\")));
            using (ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq))
            {
                ManagementObjectCollection results = mos.Get();
                foreach (ManagementObject obj in results)
                {
                    foreach (PropertyData p in obj.Properties)
                    {
                        //See if the current scheme is the current setting. This will happen twice, once for AC and once for DC
                        if (p.Name == "InstanceID" && p.Value.ToString().Contains(PowerPlanInstanceId.ToString()))
                        {
                            //Change the value of the current setting
                            obj.SetPropertyValue("SettingIndexValue", (enabled ? "1" : "0"));
                            obj.Put();
                            break;
                        }
                    }
                }
            }
    
            return true;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in FireFox 'options' => 'content', I can turn off JavaScript and image loading by
Does anyone know how you can turn off autocompletion on a textfield in Django?
When using NUnit, I can turn off shadow copy so that my test assemblies
how can one turn off the error messages of a bash script? I want
How can I turn off JavaScript shortening in A4J? I remember there was an
How can I turn this behavoir off? It happens when you enter a close
For normal input elements you can turn off the spell checking by using a
Possible Duplicate: Can I turn off impersonation just in a couple instances I've created
I am developing a game in which the user can turn on / off
I have a pure Objective-C project (no C++ anywhere). Can I turn off GCC_ENABLE_CPP_EXCEPTIONS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.