For the last few months I’ve had Windows 7 RC installed on two home computers, and both of them have exhibited a strange problem: They would randomly wake from sleep .
The computers would often wake up just seconds after being shut down. At other times they would wake up in the middle of the night. To make matters worse one PC, which had recently had its graphics card upgraded, would go into an endless loop of restarting without ever getting to the Windows login screen. I suspected a power problem relating to the new card.
I spent quite some time investigating these wake problems (which I believed were unrelated) but could not diagnose the issue. Eventually I gave up and had to disable sleep on both machines (which pained me greatly!).
Last week I had a second wind and was determined to resolve this problem once and for all. I figured there must be a tool that could tell me what caused the wake up events, and after some research I discovered the Vista/Windows 7 powercfg tool.
To use this tool you simply type powercfg –lastwake at the command prompt

In the above screenshot you can see the computer was woken by something on the USB hub (my mouse in this case). But much to my annoyance, when I ran this tool after a phantom wake it reported the type was “Unknown”!
Because I had a suspicion this could be a wake-on-lan (WOL) behaviour I used the WireShark network analysis tool to monitor network traffic for WOL packets. Perhaps a third computer had been infected with malware and was trying to wake other computers to have its wicked way? Unfortunately nothing showed up on the wire.
No further progress was made until I randomly stumbled across a forum posting about a network adaptor setting called “Wake on pattern match“. I checked both my PCs and this setting was enabled. It appears this obscure setting is enabled by default in Windows 7 for Realtek RTL8168B/8111B and RTL8168C(P)/8111C(P) Family Gigabit Ethernet NICs.
What does “Wake on pattern match” actually do?
Most people are familiar with Wake-on-LAN which uses a “magic packet” (hard-coded) to trigger a wake event. Well it seems that feature has been superseded by the more flexible “Wake on pattern match” capability. According to this Microsoft Article on Power Management for Network Devices:
The packet patterns that define the wake-up frames [for "wake on pattern match"] are provided to the NDIS 5.0 miniport driver by the operating system. At runtime, the protocol sets the wake-up policy using OIDs. These are, for example, Enable WakeupSet Packet PatternRemove Packet Pattern. Currently, the Microsoft TCP/IP is the only Microsoft protocol stack that supports network power management. It will register the following packet patterns at miniport initialization:
- Directed Layer Two packet
- Address resolution protocol (ARP) broadcast for station IP address (frames with DIX header)
- NetBIOS over TCP/IP broadcast for station’s assigned computername (frames with DIX header)
I am no networking expert but the last two sound like they could be pretty common activities on your typical home network. If so it’s no wonder my computers were exhibiting such crazy wakeup symptoms. (Either that or I have got a renegade PC on my networking sending out these packets).
The solution? Simply disable the “Wake on pattern match” setting under the network adaptors advanced properties tab, as shown below:
My biggest mistake? I could have short circuited the resolution of this problem by testing my computers without the Ethernet cable plugged in right at the start. The reason I didn’t was I couldn’t understand how a WOL packet could possibly be being sent so I ignored the possibility.
Now I know about “Wake on pattern match”, next time I will be prepared.
#1 by dak664 on August 12, 2009 - 11:10 pm
Quote
Great, maybe it will prevent my wakeups. I have an onboard nvidia 8300 chipset which loads its own ethernet driver, and was redirected to their control panel which does pretty much the same thing.
powercfg has an unusual output with smileys:
$ powercfg -lastwake
Wake History Count – 1
Wake History [0]
Wake Source Count – 1
Wake Source [0]
Type: Wake Timer
Owner: [DRIVER] ☺ (☺)
#2 by Shane Collins on August 27, 2009 - 9:19 pm
Quote
Thank you. I’ve been putting my computer to sleep a lot lately because I randomly fall asleep, and when I know it’s coming around, just put my computer to the same task. I’ll wake up randomly in the night and lo and behold! My computer’s on, with my LCD screen displaying a black screen and my mouse showing where it was last at. I hated it. I would start pulling the power cable from the computer every time I turned it on sleep to keep that from happening again.
Thank you. Let’s see if this works.
#3 by Jack on August 27, 2009 - 9:35 pm
Quote
Good luck!
Unfortunately it seems there are lots of causes for randomly waking computers, but I hope this fix works for you.
Let me know how you go….
#4 by Jon on August 28, 2009 - 2:35 am
Quote
Awesome … hope this explains my own issues. Sometimes my HTPC goes to sleep and stays there, and sometimes it wakes up within seconds. I hope this is the solution.
#5 by Jack on August 28, 2009 - 11:55 am
Quote
Jon,
Out of curiosity do you have the same network card? (presumably you are on wired ethernet too?)
Jack
#6 by Jon on August 28, 2009 - 12:35 pm
Quote
My htpc is on wired LAN, yes. It uses a different NIC but has the same advanced options. Suspect this is a Win7 setting rather than specific to network cards. I used the fix you state and my CPU is staying asleep.
#7 by Jan Willem Jansen on September 14, 2009 - 6:10 am
Quote
Thanks, last week I installed 7 RC, and I’ve got the same problem with my Dell XPS 420. Changed the Intel network settings, and no wake up anymore!
#8 by SC on October 22, 2009 - 7:35 pm
Quote
Also; change the time Windows Update installs its updates..
#9 by mike d on October 25, 2009 - 9:52 am
Quote
Any suggestions on when it wil never wake up and I have to reboot? This is happening on both a desktop and laptop. Both have up to date bios.
#10 by Jack on October 25, 2009 - 11:29 am
Quote
Almost certainly a driver problem. Try running powercfg -energy too see if it reports any problems.
#11 by Eddy Young on November 2, 2009 - 7:02 pm
Quote
Hi,
Thanks for posting this. I was quite surprised this morning when on the train, without an Internet connection, I saw e-mail in my inbox which was received in the middle of the night. I feared that my laptop had been infected, but your post is re-assuring. I will check this setting later today, although I may keep it as a “feature” for retrieving my e-mail before I head to work
– Eddy.
#12 by Vince on November 12, 2009 - 5:00 am
Quote
I tried your tip, but it didn’t work. I thought it may have been a program keeping my computer from entering sleep mode. I went through the entire task manager stopping processes to no avail. Then I went through my hardware and found an interesting check box on my infrared receiver, which I purchased to control the Windows Media Center. I unchecked “Allow this device to wake computer” and it goes to sleep perfectly now.
#13 by Bruiser P on November 22, 2009 - 9:03 pm
Quote
Thank You!
My Win 7 box would not go to sleep or was waking up randomly. I had tried a few different things to fix it but had missed wake on pattern match, never had heard of it before either. This has solved my problem so thanks again.
#14 by My Name on December 7, 2009 - 7:22 am
Quote
Great solution!
The first command help me to found the right problem. In my case it was Windows Media Center.
Just need to remove from scheduled tasks.
#15 by Dennis V on January 1, 2010 - 3:27 am
Quote
For me, it was under the Power Management tab. If you right click a device like your mouse or networking device, there should be a tab to the far right called Power Management. Uncheck the option that says “Allow This Device to Wake This Computer”. That seems to work for me.
#16 by Erik-X on January 3, 2010 - 5:53 pm
Quote
Windows 7 awakes randomly…This is what worked for me…disable allow wake timers setting under sleep category. This can be found in control panel, power options, advanced settings.
#17 by Arthur on January 11, 2010 - 3:29 pm
Quote
Thanks for this, I was also having some issues with Window 7 RTM sleep functionality. This seems to be a step in the right direction.
#18 by Jerry Mandelkehr on March 12, 2010 - 3:02 pm
Quote
When I have been away from my computer and it turns off, the only way I can open it up is to click the start button on the computer. It does not open up when I move the mouse or hit the space bar.
#19 by Alexander on March 13, 2010 - 9:08 pm
Quote
Thanks, the first command revealed mcupdate_scheduled as the cause for my startup. Up until now I didn’t even know software could wake my computer like that.
#20 by Lars on April 22, 2010 - 12:29 am
Quote
Thank you for posting this. I had a similar problem with my Dell Latitudue E6500 with an Intel 82567LM Gigabit network adapter. Searching the Control Panel gave some red herrings about when to sleep, but failed to find the solution, which is similar to yours:
On the network adapter’s properties dialog’s Power Management tab, it has two options for “Wake on LAN”; I turned them both off, and the problem was solved.
#21 by Lawrence on April 22, 2010 - 4:59 am
Quote
Thank you so much, my computer was exhibiting similar symptoms and your article helped me solve the problem.
A+
#22 by Tom on May 1, 2010 - 1:07 pm
Quote
Thanks so much. When i checked what was waking up my computer sure enough it was the gigabit network adapter.
#23 by Gotrek on August 4, 2010 - 4:17 am
Quote
Thanks a million dude. I’ve been trying to find the solution to this issue for weeks, read so many different “solutions” on so many pages I was ready to give up.
Using -lastwake showed the usb root hub so I started unplugging usb devices. Turns out my wireless mouse dongle was waking it up even when the mouse power button was switched off. Changed the power management in device manager to not let it wake the PC and problem solved.
Many, many thanks.
Pingback: Random crashes W7 64 (Sleep problems) - Page 4 - Overclock.net - Overclocking.net