Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not particularly fond of windows 7's energy management features.

I think it's really cumbersome as I seem to have to change the current plan to do anything. And sometimes I don't want to change the plan - sometimes I just want to instruct the computer to do everything it's doing, just not automatically sleep cause I'm downloading something.

But it seems every time I want to do this, I am made to go through a number of different screens and options and then I have to remember to reset it back afterwards.

Is there a program or application that allows me to just temporarily override the options within my plan, with options like Do Not Sleep button? Or "Instantly Turn Off Monitor" button or "Don't go to sleep when I turn off lid" button.

share|improve this question
up vote 2 down vote accepted

There's a free program called Insomnia that will keep a computer awake as long as it's running.

http://dlaa.me/blog/post/9901642


Since the link has already changed once, here is the important part of the program source taken from the link above so that it can be reproduced if the link ever goes down permanently.

public partial class Window1 : Window
{
    private uint m_previousExecutionState;

    public Window1()
    {
        InitializeComponent();

        // Set new state to prevent system sleep (note: still allows screen saver)
        m_previousExecutionState = NativeMethods.SetThreadExecutionState(
            NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);
        if (0 == m_previousExecutionState)
        {
            MessageBox.Show("Call to SetThreadExecutionState failed unexpectedly.",
                Title, MessageBoxButton.OK, MessageBoxImage.Error);
            // No way to recover; fail gracefully
            Close();
        }
    }

    protected override void OnClosed(System.EventArgs e)
    {
        base.OnClosed(e);

        // Restore previous state
        if (0 == NativeMethods.SetThreadExecutionState(m_previousExecutionState))
        {
            // No way to recover; already exiting
        }
    }

    private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
    {
        // Start an instance of the NavigateUri (in a browser window)
        Process.Start(((Hyperlink)sender).NavigateUri.ToString());
    }
}

internal static class NativeMethods
{
    // Import SetThreadExecutionState Win32 API and necessary flags
    [DllImport("kernel32.dll")]
    public static extern uint SetThreadExecutionState(uint esFlags);
    public const uint ES_CONTINUOUS = 0x80000000;
    public const uint ES_SYSTEM_REQUIRED = 0x00000001;
}
share|improve this answer
    
thanks it works! although i might fig with the program a bit to have some additional features i want. – RoboShop Nov 7 '11 at 9:38

You could write a batch file to do this. Something really easy. There is a command in Windows 7 that allows you to adjust the Power Management features. Your batch file could be setup to prompt you for different features and based on how you answer the settings would be changed. Here's a start. I had used this command to automatically disable the sleep feature in Windows 7 and it worked well.

share|improve this answer
    
Patrick S. post made me remember this. a great little application called caffeine. Execute and it will keep your computer running until you close it! – bourne Nov 7 '11 at 0:21

My favorite way of doing this without any additional software is to use the built in Mobility Center of Windows. It can be quickly accessed using the [Windows key]+[X] shortcut of Windows 8:

Opening Mobility Center

Then simply switch Presentation Mode to on.

Turning presentation mode on

As long as this particular mode is on, the computer will not turn off the screen and will not go to sleep.

Only downside: Mobility Center is only available on mobile computers, as far as I know.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.