Give your computer insomnia [Free tool and source code to temporarily prevent a machine from going to sleep!]

This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of

See you there!

Comments (111)
  1. mrjvdveen says:

    Nice tool. I do have to say that Windows 7 does a much better job on putting a computer to sleep only when possible. If I for example have my p2p client active it will not go to sleep, but as soon as I shut it down, it does. Also when I use mediacenter and schedule a recording it will go to sleep but will wake up in time to start recording. Really cool stuff.

    I’m not sure if they changed stuff in the API though.

  2. Anonymuos says:

    Now all you need to do is:

    1.  Add an option to start it only in the tray.

    2.  Hide the tray icon by default when run once as an option and make it appear if run the second time.

    3.  Add a minimize button.

    4.  Pretty it up a little bit.

  3. David Anson says:


    I touch on this in the post a bit, but I had a specific goal with Insomnia that it should NOT be possible/easy for the user to forget that the program was running and suppressing the default sleep action (and also that the application should be super-easy to use). This goal seems to be in fairly direct opposition to your suggestions 1, 2, and 3, and that’s part of the reason I didn’t take that approach already. Regarding your suggestion 4, I have no defense, save to admit that I have no measurable design skills whatsoever and beg your forgiveness for the ugly UIs I tend to come up with. 🙂

  4. Alex_ says:

    Anyone has compiled a version with the Topmost property set to false? I´m actually not a developer nor have Visual Studio installed, so it´s a major hassle to get to compile it (I did some research but it seems with XAMP files, it cannot be done by command line without VS)

  5. David Anson says:


    I’m a big fan of the Visual Studio Express Editions for stuff like this. They’re *free*, relatively small, and they do a really great job supporting common coding scenarios. If you give Visual C# Express a try, not only will you be able to make this tweak, but you’ll be able to play around with other changes as well!

    Here’s a link with more information:

    PS – To prove I’m serious, let me say that I do all my development at home using the Express editions!

  6. marktherob2010 says:

    I love this little program, could you put it in the tray?



  7. David Anson says:

    Thanks for the kind words, marktherob2010!

    When I wrote Insomnia, I was worried about someone forgetting they had it running and accidentally leaving their computer on all the time. So the first version of Insomnia is Topmost and can’t be minimized. However, you’re not the first to make this request, so I’ll be adding support for "minimize to tray" soon.

    Thanks for your patience! 🙂

  8. obvious says:

    This was a much needed app. Thanks! I wonder if it would be straightforward to add a right click context menu while in the tray or pinned for Pause and Resume?

  9. David Anson says:


    Thanks for the feedback! Regarding pause/resume, wouldn’t it be almost as easy to close the app and restart it? Otherwise I worry about people seeing the "I" icon in the tray and getting confused – unless I change the icon graphic, too. But then all of a sudden the simple app is starting to get more and more complicated… 🙂

  10. KKK says:

    Just tried the tool on WinXP SP3 and had no effect.

    Windows is going to sleep mode and hibernation without problems, while the window is open

  11. David Anson says:


    Sorry about that! While I haven't tried it on XP SP3 I'd expect it to work based on the MSDN documentation and the fact that nobody else has reported this problem. Is there any chance the behavior might be unique to that machine? If you don't think so, I could set up a virtual machine with XP SP3 to try this out myself.

  12. Jad says:

    I set it up as a scheduled task so when my weekly auto-backup runs, the computer stays awake for a few hours to give "Carbonite Backup" time to upload the backup file to their servers.


  13. Jad says:

    ps:  the "end task if it runs for xx hours" effectively kills insomnia after the time I want it to be active 🙂

  14. David Anson says:


    Cool scenario, thanks a bunch for sharing!

  15. Daddy says:

    yea it doesn't work for me either on WIN XP SP3 🙁 … Would the fact that it is a work machine and has a group policy assigned to it make a difference? It maybe that the registry cannot be changed??


  16. Daddy says:

    I tell a lie….. it is working 🙂  the screen saver was just starting up but it didn't lock out. excellent!! thanks a mill….. i can take a snooze at work now 😛

  17. David Anson says:


    Glad to hear it!

  18. max says:

    the downloading link seems to be dead 🙁

  19. David Anson says:


    It worked for me just now. Could you please try again now or in a couple of hours, maybe?

  20. Neil says:

    Great!  Now I can reset power options back to default sleep and remove the Power Options shortcut from my Desktop.  Have only had this Win7 machine since September and already the sleep mode (changing it) was a pain whenever I performed large backups.  THANK YOU!  FYI I found out about your utility through "Free Download A".

  21. Paul says:

    A hidden folder called "insomnia" has appeared unbidden on my computer, and copies itself to any USB device I use. It contains a file called jkdrolja.exe. Is this the program you are talking about?

    I can't delete it or uninstall it. How can I get rid of it?

  22. David Anson says:


    I'm sorry to hear that – it sounds like you may have some malware on your hands. The Insomnia program I discuss in this blog post does *none* of the things you mention. You might want to consult the Microsoft Malware Protection Center for help diagnosing your machine:…/portal

  23. Wide Awake PC says:

    Steps to change your computer's "sleep settings" manually.

    Start Menu

    Click on Hardware and Sound

    Under Power Options click the tab that says Change when computer sleeps

    Then just scroll down to select your desired settings.

    My computer would sleep when I would be uploading with FTP to my website or running system scans. So glad I found this post, even though I didn't use the tool. I used the comment submittted by Neil & just figured out how to do this on my own since he didn't elaborate…

  24. lol says:

    when i try and like close my laptop, get the screen to go down and make it flat, the computer sleeps when insomnia is open. tell me if you don't get it.

    is there anything i can do?

  25. David Anson says:


    Insomnia doesn't prevent the computer from going to sleep when something explicitly tells it to. If you wanted, you could also put an Insomnia-running computer to sleep by selecting "Sleep" from the Start Menu. To solve your problem, I think you want to go into the "Power Options" control panel and find the option for "Choose what closing the laptop lid does" – it's probably set to "Sleep" now and you want to change it to "Do nothing".

    Hope this helps!

  26. Arnold says:

    Hi, Downloaded the Insomnia files (four folders) on the basis of Kim Komando's recommendation. But I'm lost without an install wizard. Where should I save the files, and how do I run the program?


  27. torque armada says:


    i just downloaded this and it is an executable file, it doesn't need installing. all you need to do is unzip the download, choose 32 or 64 bit depending on your computer, and double click "Insomnia.exe". that's it.

  28. donby says:

    After installing I do not, or can not , find anything on my desktop to activate the thing.

  29. Nippit says:

    So…Pleeaazzzeeee…tell me your not Tom DeLay…that Texas Idiot…?

  30. Roger says:

    I've tried running this on two machines, both Win XP SP3. Extracted 32-bit .exe file. When I try to run it, it reports "The ordinal 380 could not be located in the dynamic link library COMCTL32.dll" What to do????

  31. David Anson says:


    As "torque armada" says, you can put the Insomnia.exe file anywhere you want and run it from there. There are three versions in the ZIP – when in doubt about which to pick, the 32-bit version is a good choice as it should run nearly everywhere.

  32. David Anson says:


    Please see my comment above – you'll want to run one of the three versions of Insomia.exe from the ZIP file you downloaded.

  33. David Anson says:


    No relation to him, actually. 🙂 The "About" box at the top of the sidebar has a bit about who I am.

  34. David Anson says:


    It's possible the version of COMCTL32.dll that comes with Windows XP SP3 doesn't export that method; I'll look into this in the next few days. For now, assuming you have the .NET Framework installed on that machine, you should be able to run the .NET version of Insomnia.exe just fine.

    Please let me know if that's not the case – thanks!

  35. Tim says:

    I downloaded this off KimKomando as well.

    I'm running WXPpro SP3 and after unzipping I put a shortcut on my desktop to the app inside the NET folder.

    Doubleclick the shortcut then click RUN and badabing!

    Clicking the other folders resulted in probs but the 'net' runs fine for me!

    Unfortunately I am totally clueless how this app works, but the source code is there to tempt me to perhaps learn something besides clicking.


  36. David Anson says:


    I've looked into the Windows XP (SP3) issue just now – the "ordinal 380" error is due to the fact that the LoadIconMetric API isn't supported on OSes prior to Windows Vista. It's easy enough to use the more general LoadIcon API and then native Insomnia starts successfully on XP – but it doesn't show any text. The missing text is because the LM_GETIDEALSIZE message isn't supported prior to Vista, either – and in this case the simpler LM_GETIDEALHEIGHT message isn't a direct substitute. What's more, the current icon doesn't seem to be recognized by XP, either (it shows the generic application icon in Explorer and nothing in the tray). Neither of these issues (text measurement and icon) are overly difficult to fix, but they're also not trivial and I'm not sure how worthwhile it is to spend time and effort to support native Insomnia on Windows XP when the .NET version is reported to work just fine…

    That said, I'm open to input here. If a lot of people think this is useful, I'll look into doing the work – but if everyone's happy to use the .NET version on XP, I'm happy to let them. 🙂

    Thanks for the feedback – please let me know what you think!

  37. MikeyD says:

    Since I have WIN XP SP3, I will just use the .NET version, as recommended. But does it need to be installed in a particular folder, or is my own "Utility" folder a valid location?

  38. David Anson says:


    Each version of Insomnia.exe is completely stand-alone and can be copied to and run from any folder/location you choose. 🙂

  39. Roger says:

    Delay, Thanks for investigating. I tried both the 32-bit version and the .net version on one computer, and neither works. So, on the other computer I only tried the 32-bit version, which didn't work there either.

    But, this morning I tried the .net version on the 2nd computer, and found that it works. That machine has .net Framework 1.1, 2.0 SP2, 3.0 SP2, and 3.5 SP1 installed.

    On the first machine, only .net Framework 1.1, and 2.0 are installed. When I try to run Insomnia .net there, I get the dreaded "Insomnia has encountered a problem and needs to close. We are sorry for the inconvenience" message.

  40. David Anson says:


    That sounds right – managed Insomnia is a .Net 3.5 application and won't run on machines without that version (or later) installed. .Net 3.5 comes with Vista and later, but folks running XP may not have it if they didn't accept the Windows Update offering. I'm thinking I'll probably end up getting native Insomnia running on XP, but it's not my highest priority at the moment. 🙂

    Thanks for following up!

  41. rambo says:

    Insomnia works great to keep my Windows 7 awake.  I love it.  However, my monitor still goes to sleep.  Do you have something to keep it awake too?  Thanks!

  42. David Anson says:


    Thanks – that's great to hear! 🙂 At present, Insomnia deliberately does NOT prevent the monitor from entering its power-saving mode because saving energy seems desirable in pretty much all the scenarios I originally had in mind. But you're not the first to ask about an option to keep the monitor on – would you mind sharing more about what your scenario is and why you want to keep the monitor on?

    Thank you!

  43. rambo says:

    This is for home use so I like to keep my PC awake for the few hours I get to use it in the evening.  For that couple hours, I'd like to be able to walk away for 15-30 minutes and come back to an awake PC and monitor.  No biggie, but since now I can keep the PC awake with Insomnia, I'd like to keep the monitor awake also.  At the end of the night, I close Insomnia and we all go to sleep. 🙂  I would love to see either another bit of software to keep the monitor awake or add it as an option in Insomnia.  Whatever is simpler.  Thanks!  

  44. David Anson says:


    Actually, the simplest solution for your scenario may not involve Insomnia at all. 🙂 The Power Options Control Panel has a page that lets you choose when the computer goes to sleep and when the monitor powers off – it sounds like you want to set both of these to "Never" and then just pick Sleep from the Start Menu before going to bed at night. As long as you're not subject to Group Policy settings that block these settings, this should do exactly what you want.

    Hope it helps!

  45. Duck says:

    Nice program. Unfortunately the 32bit exe doesn't work on WinXP and I don't have .NET installed on WinXP either.

    Are you going to be working on a native version for WinXP? If so, I will wait for it. If not, I may try again with .NET installed. Which version will I need? .NET 2.0?

  46. Duck says:

    Oh but if this is true… "Insomnia doesn't prevent the computer from going to sleep when something explicitly tells it to." Then I think this program is not what I am looking for because it will be another app that tells the computer to sleep that I am trying to stop. So never mind.

  47. David Anson says:


    This comment above discusses the Windows XP problem (missing APIs):…/give-your-computer-insomnia-free-tool-and-source-code-to-temporarily-prevent-a-machine-from-going-to-sleep.aspx

    And this one discusses the .NET requirement (3.5):…/give-your-computer-insomnia-free-tool-and-source-code-to-temporarily-prevent-a-machine-from-going-to-sleep.aspx

    I'll count your feedback as a vote for Windows XP support. FYI to you and others that XP support is now officially on my TODO list. 🙂


  48. rambo says:

    Sleep in the Start Menu?  I don't see it anywhere in my Start Menu.  Can I add it?  How?  Thanks!

  49. David Anson says:


    Click the Start Menu orb, look to the bottom-right of the Start Menu where the "Shut down" button is, click the ">" arrow that appears at the right edge of that button, then choose "Sleep" from the bottom of the resulting popup menu. 🙂

  50. rambo says:

    Never noticed that.  I like it!  Thanks!  

  51. skulldrinker says:

    I see it works even from the Flash Drive.

  52. skulldrinker says:

    I just put this on my laptop so when i watch a Netflix movie it would stay on but after about 10-15 min my screen stills goes to black with the XP logo floating around. The sound stays on I can hear the voices just no picture. Am I confusing Sleep with something else?  I even had the setting set to Never and still the screen goes to xp logo after 15 min.

  53. David Anson says:


    Yep, running from a flash drive is fine. 🙂

    Regarding the Netflix issue, there's a difference between a computer going to sleep (it's like turning off, but things stay in memory so it's quicker) and the screen saver starting (which was originally intended to prevent screen burn-in). In your case, the computer did not go to sleep (you can tell because the sound stayed on) but the screen saver did kick in (the default XP one, it sounds like). Insomnia is not (currently) intended to prevent the screen saver from running. The problem here is likely with the Netflix application which should expect keyboard/mouse inactivity during a movie and temporarily disable the screen saver to avoid this very problem – maybe it didn't try or maybe it tried and failed…

    Please have a look at my reply to an earlier comment for an easy way to disable the screen saver (permanently):…/give-your-computer-insomnia-free-tool-and-source-code-to-temporarily-prevent-a-machine-from-going-to-sleep.aspx

    I'm considering adding screen saver prevention to Insomnia, but it'll be a little while before I'd get to it. 🙂

  54. skulldrinker says:

    Well that was my problem. I didn't realize the screen saver was set to come on at 10 min. I turned it off and now my troubles are over. Thanks. skulldrinker from chicago.

  55. curious says:

    can i ask something? does this program work with guest account?

  56. David Anson says:


    If you can run it, it should work. 🙂

  57. DeuxIt says:

    Thanks for this. The big MMO download kept being interrupted by the PC sleeping. Perfect tool.

  58. ben says:

    it doesn't work for Installation!

  59. David Anson says:


    I'm not sure I understand your comment – there is no installer. 🙂 Each version of Insomnia is a completely self-contained executable (EXE) that can be run from any location.

    Hope this helps!

  60. 252 says:

    Feature request: It would be nice if windows had options for not sleeping if any hdd or network was in use. Is there any way you can add this to insomnia when above a certain threshold and then go back to normal sleep mode?

  61. David Anson says:


    I think that's one of those things that sounds easy, but ends up being quite tricky in practice. Although a specific application can know that it is doing something important enough to block sleep (ex: DVD burning, movie playing), I think it would be quite difficult for Insomnia to make that determination about a *different* application it has no visibility/insight into. Even when present, network and disk activity could be occuring for a wide variety of reasons and sorting out which of those were important and which were not seems like it would be beyond the scope of a simple tool like Insomnia. 🙂

    If I have any good ideas here, I'll definitely follow up on them. But for the time being, please don't hold your breath waiting for this. 🙂

  62. help says:

    I just downloaded this and I am having trouble it just opens a blank camera and scanner wizard and nothing else how do i get

    it to work.

  63. David Anson says:


    The download is a ZIP file which contains three EXEs (.NET, 32-bit, and 64-bit) and some source code. The EXEs should be copied to your disk before being run. Nothing here should open the camera and scanner wizard, so I'm thinking maybe something is hooked up strangely on your machine. You don't say exactly what steps you're following, but if using Windows Explorer to open the ZIP isn't working well, maybe you could try something else like WinZip, etc.? Also, please try both the .NET and 32-bit versions just to be thorough.

  64. Dale says:

    Nice tool, thanks very much for sharing it! If you're still in the mode of suggestions for new features, how about a "time to live" – the amount of time after which the window will close. I like to start a malware scan manually at times, and would like the computer to stay awake for say, an hour.

  65. David Anson says:


    Glad you like it! 🙂 Also, I've added your suggestion to my TODO list.

  66. Birk Binnard says:

    I plan on using this trick to keep my Win7-64 SP1 system awake during video rendering sessions (which can last several hours.) I have installed Insomnia and it does work as stated.  However, it also changes the behavior of my system as follows:

    I have a function-key assigner that allows me to put various command strings on keyboard function keys. I have put the following command on a key to put my system into Sleep mode: Rundll32.exe Powrprof.dll, SetSuspendState Sleep

    This works as desired.  However, prior to installing Insomnia my system would wake up directly from sleep mode by simply hitting a key.  Now when I do that instead of waking up directly I get the BIOS flash screen followed by the Resuming Windows screen.  The roughly doubles the overall wake-up time.

    What is more peculiar is that if I use the standard way to enter Sleep mode (Start/Shutdown/Sleep) the system goes to sleep normally and wakes up the way it did before Insomnia – there is no Bios screen or Resuming Windows screen.

    My system does have an SSD boot device but is otherwise strictly vanilla.

  67. David Anson says:

    Birk Binnard,

    What your custom command is doing probably maps to the following Win32 API:…/aa373201(VS.85).aspx

    My *guess* is that when it's run when Insomnia has already suspended sleep mode, the sleep attempt turns into a hibernate. Hibernate typically writes memory to disk, powers off more completely, and reads the memory back after wake-up. It's usually *much* slower than sleep mode because of the disk access, but your SSD is probably minimizing the impact of that so it's not as obvious. As far as I can tell, all the symptoms here point to hibernate vs. sleep – you could maybe even verify this by checking the Event Log or using powercfg.exe to identify what kind of suspend/resume has just been performed after resuming from one of these "slow wake-ups".

    I hope this helps to explain the situation – please let me know if you investigate and confirm or deny any of this! 🙂

  68. Birk Binnard says:

    I tried to post a response here (twice!)  but neither one ever showed up.  If this one dies I will try again.

  69. David Anson says:

    Birk Binnard,

    FYI that the blog software can take a little while to show new comments. However, it looks like it this one got through okay. 🙂 What's up?

  70. Birk Binnard says:

    There must be some bug in this forum software….3rd attempt to post reply never made it

  71. Birk Binnard says:

    I used powercfg to turn off HIbernation. Now everything works ok – my keyboard command puts the system into "fast wakeup" sleep mode which I guess is the real Win7 Sleep mode, as opposed to the Hibernate mode.  I also got back all the space (4.4 GB)  used by the hiberfil.sys file. So I guess I'm happy now – although I'm not sure how hibernation got turned on.  I know I disabled it when I installed my SSD.

  72. David Anson says:

    Birk Binnard,

    I'm not sure what could have enabled hibernation, either. At any rate, I'm glad to hear you sorted things out! 🙂

  73. Lori says:

    Hi!  I've tried your program and its not working.  I have a Lenovo ideacentre all in one running 64bit Windows 7.  I think my issue is that when the display turns off, the speakers (integrated) turn off.  So it does keep my computer from sleeping, but doesn't do what I want.  Any help?  I'd love to get this to work!

  74. David Anson says:


    Insomnia only tries to keep the machine running and it sounds like that's working for you. If your theory about the speakers being linked to the display power is right, you may be able to keep the speakers on by disabling screen shut-off in the Power Options Control Panel. While you're there, check out some of the other options because there might be an even better way (such as switching to the High Power profile).

    Hope this helps!

  75. Ztgreve says:

    I have a couple of ideas:

      1. For a tray version, you could have a tool tip pop up every 5 min. or so

         1.1 The time could also be configurable.

    Otherwise, nice app! I will use it to keep my Dell awake while Dragon Naturally Speaking downloads and installs a 1.2 GB Service Pack.

    It kept failing because my computer would go to sleep during the download.

  76. David Anson says:


    Interesting idea, thank you for sharing! I haven't had nearly the issues I worried about since allowing Insomnia to be minimized (…/the-customer-is-always-right-updated-free-tool-and-source-code-to-prevent-a-machine-from-going-to-sleep.aspx), so I'm not nearly as worried about this as I once was. 🙂

  77. Desmond says:

    I wrote an alternative to Insomnia called Caffeinated. It's very similar, except in my opinion Caffeinated has a better user interface. Try it here:

  78. Eric says:

    Just ran .exe 32 file and now have the little icon in the system tray…hope this works!  I'm running a bunch of batch files that execute Access macros that update XL files, move text files etc. on my work desktop.  The eventual plan is to move this processing to a dedicated machine/server but first I have to prove conceptually that the processes I'm running will work.  Problem is that I'm running the batch jobs overnight and my pc logs out during inactive times.  If Insomnia works, it will be a HUGE deal for me.  Keeping my fingers crossed; I'll keep you posted.  Thanks!

  79. Hello. Does "insomnia" work if it is minimized to the tray or does it have to be open on the desktop?  Thank You.

  80. David Anson says:


    Once running, Insomnia will work whether it's minimized or not. 🙂

  81. Francesco Montorsi says:

    Hi David,

    I've created a MATLAB implementation of insomnia! I find it very useful when doing long simulations on home/office workstations!

    It's available at:…/36194-insomnia-prevent-computer-sleep-mode


  82. David Anson says:

    Francesco Montorsi,

    Cool idea! I still have fond memories of using MATLAB to animate the path of an airplane for a CGI course in college… 🙂

  83. Luc (Antibes FR) says:

    Work like a charm on XP SP3 !

    Good response and tweak to this (stupid) Microsoft behavour :…/318355



  84. Aaron says:

    Cool program.

    Now I can download large files unattended without having network connection interrupted when PC goes to sleep.

    Display power off when mouse/keyboard inactive also saves power for my laptop.


  85. morofo says:

    Is there a simple way to change the text displayed in the box? I'm working with non-english users and they would close the box if they don't understand it. Thanks for this.

  86. David Anson says:


    If you're comfortable building the source code I include, it's easy to change the strings and recompile. If it's for the native version (32- or 64-bit), you can use a resource editor like Visual Studio to edit the strings directly in the EXE you have. Alternatively, the strings could be localized via standard means (satellite assembly, MUI, etc.), but I haven't done the work to support that.

    Hope this helps!

  87. morofo says:

    Thanks for the answer. I'm not a programmer/coder, just an IT tech. Anyway, I've found a way to do it while searching for something else. It's Resource Hacker

    ti seams to be ok for just changing the message.

    thanks again for both insomnia and the answer.

  88. fcol says:

    I completely support keeping insomnia in your face so that you don't forget it is on.

    There is an app on the Mac called Caffeine that also prevents sleep but is a rather unobtrusive small icon in the upper panel and is all too easy to forget. It is true that Caffeine gives you choices for how long you want it to stay on, but I still prefer the Insomnia approach and hope you don't change it.

  89. David Anson says:


    Thanks for your support! 🙂

  90. Top work David.

    Works great on Win 7 Home 64-bit.



    PS. It might be worth adding some SEO terms to this page. I Googled 'Stop windows from sleeping' and took a while to come across this perfectly suitable too 🙂

  91. Danny says:

    would this work on Windows 8?

  92. David Anson says:


    Yes, it should.

  93. random says:

    this is a slick little program and from what i can find on the web everyone likes it and the message that stays up is a good call. leaving it on could be potentially hard on a computer

  94. WormyWyrm says:

    In reply to:  David Anson 28 Dec 2010 3:20 PM #

    lol,  Insomnia doesn't prevent the computer from going to sleep when something explicitly tells it to. If you wanted, you could also put an Insomnia-running computer to sleep by selecting "Sleep" from the Start Menu. To solve your problem, I think you want to go into the "Power Options" control panel and find the option for "Choose what closing the laptop lid does" – it's probably set to "Sleep" now and you want to change it to "Do nothing".  Hope this helps!


    Dan, there are also options under "Power Options" to disable sleep after a certain amount of time passes.  Isn't the point of this program is that it temporarily disables the computer from going to sleep?  I think it would make sense that it also temporarily disables lid closure from putting the laptop to sleep.  Thx.

  95. David Anson says:


    There are two ways a computer can go to sleep: because it was idle for too long or because it was asked to. Insomnia prevents the idle time-out which makes it suitable for keeping the computer awake every now and then to complete some task or other without going to sleep. Actions like closing the lid can be configured to put the computer to sleep and Insomnia doesn't get in the way of that because it's a specific request that was user-initiated. The way Insomnia behaves happens to match the behavior of the underlying Windows API it calls – this is not entirely coincidental. 🙂

    It could be changed to work the way you suggest, but I find the way it works today to be consistent with how most people expect and want.

  96. Robin says:

    One feature that might be nice is to have it respond to WOL packets to the discard port to remain insomniac for another 20 minutes, otherwise restore normal system behavior.  This would involve finding the MACs of the interfaces, or just responding to 48 ones as an interim measure.  Does this compile with MiniGW?

  97. David Anson says:


    That's a really neat idea! It's also a lot more involved than the single API call wrapper that Insomnia currently is. 🙂 If you experiment with this, please let me know how it turns out.

    Regarding compiling under MiniGW, I haven't tried myself, but Insomnia is one of the simplest Win32 apps you can imagine, so I'd expect it to work without too much hassle.

  98. Tom Hock44 says:

    Hi, David,

    I have tried changing every power setting and advanced power setting to keep my Win 7 Ultimate 32 bit computer from sleeping but it still goes to sleep after about 20 minutes.  It is a desktop so doesn't have any "on battery" options.  I have tried Insomnia with high hopes, yet it still goes to sleep!  I like to use Logmein so I can access it from remote computers, but that just shows "Offline" when it is sleeping and won't wake it up.

    My Acronis True Image program does wake it up to perform backups in the middle of the night as it should.

    I am using the 32 bit version of Insomnia.

    Any suggestions?  

  99. David Anson says:

    Tom Hock44,

    Is there a chance you have some third-party power management program running? Many manufacturers include stuff like this in the tray and maybe you have one that's forcing the machine to sleep?

  100. Tom Hock44 says:

    Thanks for the reply.  I have MS Security, Logitech Keyboard, Roboform password manager, and that's about it in the system tray.  I have been trying everything for months now, and still it sleeps (or hibernates, I am not sure which).  I have used "powercfg -hibernate off" and when I run powercfg -A it shows hibernation is not enabled, so I think it is a sleep problem.

    The power on light blinks, the flash drive (which is usually lit) is dark.  When I move the mouse or press the space bar, the hard drive light blinks, there is a loud click, then the system wakes up and the screen (which was dark with its power light blinking) comes back on.

    I have been using the same programs and not added any new ones for at least 9 months.  I upgraded both this 32 bit desktop from Windows 7 to Windows 7 Ultimate and the same with my 64 bit laptop.  The laptop does not have this problem.  I have set every power setting on the desktop to exactly match the laptop and still no joy.

    For some reason, I was wondering if one of the MS updates may have started this problem.  I see lots of posts with other users having the same problem, but none of the solutions I have tried have worked.  I started a whole new power scheme and it seemed to work for a while, but it began sleeping again in a matter of days.

  101. Tim says:

    I just left my windows 8 machine running a long job with insomnia on the screen so I could monitor progress.  Imagine my surprise when I looked over to find a screen full of screen saved bubbles!

    Please debug on windows 8 and 8.1


  102. Tim says:

    ps I am running 64 bit Windows 8 enterprise client and the 64 but exe of insomnia downloaded here.

  103. David Anson says:


    I use Insomnia on Windows 8 and 8.1 regularly and can confirm it works in general. 🙂 Please keep in mind that it does NOT prevent the screen saver from kicking in, it only prevents the machine from going to sleep. Based on your description above, it sounds like Insomnia is working as intended!

  104. gautam says:

    sir can you tell me,,,

                  what is the logic behind ,,""if my pc is being shutdown,,and i am try to start from my any kind of language 'if u are satisfied of that language' please tell me sir..""    

                 or email me..– –..

  105. AJ says:

    Thank you David, after all these years I still use your little program almost everyday, really useful. Thank you

  106. Topaz says:

    OMG!  Thank you very much for this tool David.   Switching power schemes was definitely getting old.

    This script earns a place in my Archive.

  107. David says:

    Is there an alternative way to do this in Windows 8.1, without installing a program? Thanks,


  108. David Anson says:


    I'm not aware of anything new in Windows 8/8.1 for temporarily suspending sleep mode.

  109. rcc says:

    thanks, saved the day.

Comments are closed.

Skip to main content