Wednesday, April 16, 2014

perchance to dream


Do Intel chips dream of Facebook updates ?

Yes, they do. Install that Intel Smart Connect driver and your PC will wake itself up repeatedly to check for email, Facebook and Twitter updates; lathering itself into a frenzy, seeking hopelessly for validation. This is a problem if you'd rather have the machine sleep peacefully and cheaply through the night, waking cool and refreshed to do useful work.

When building my latest desktop I carefully did not install the suggested Intel Smart Connect driver. Still, there was something whispering in its ear to give it unquiet dreams. Gently put to sleep, tucked in with a comforting word each night, in the morning it would be up and humming busily. Maybe the NSA unleashed its robot crawlers to inspect my digital fewmets - questing, perhaps, for traces of renewed allegiances to those foreign princes and potentates whom I was supposed to renounce and abjure during the oath of citizenship.

It turns out there are many imps and daemons that are empowered to cause wakefulness, almost as many as hover about my own bed each night. Here's a swift trot through the ways to a better night's sleep, for your Windows 7 computer at least.

Deep in the bowels of the Windows install is a handy command-line tool powerfcg. Look for it in the folder Windows/system32.

Open a command prompt, run it with the -LASTWAKE flag, to see who it was the last time.

C:\Windows\system32>powercfg -LASTWAKE
Wake History Count - 1
Wake History [0]
  Wake Source Count - 1
  Wake Source [0]
    Type: Device
    Instance Path: USB\ROOT_HUB20\4&449fe53&0
    Friendly Name:
    Description: USB Root Hub
    Manufacturer: (Standard USB Host Controller)
Quite a few USB drives will install their own proprietary little driver, which wakes itself up periodically to see if there is any data to be moved around. Just plugging in a new USB can cause a sequence of sleepless nights.

Check to see who is empowered with the -devicequery wake_armed flag.
Wake armed ? like that bunch of lawless criminal deadbeat welshing rebels in Nevada ? No, these devices are innocuous in comparison with the America-haters.

Thus,
C:\Windows\system32>powercfg -devicequery wake_armed
HID Keyboard Device
ASMedia XHCI Controller
USB Root Hub
HID-compliant mouse (002)
Atheros AR8151 PCI-E Gigabit Ethernet Controller (NDIS 6.20)

Off we go to go to Control Panel, Device Manager, expand each node looking for something that matches the device name as listed above, rightclick on that device name and select Properties, then on Power Mgmt tab for each of these, uncheck 'allow this device to wake'.

Looks like this,


 and then after the right-click, properties etc,


The keyboard was left allowed to wake, so a keystroke will awake it, but all other devices are disarmed.

Programs can also goad the exhausted boards back into action. See the Windows FAQ on sleep,
To prevent programs from waking your computer
    Open Power Options by clicking the Start button, clicking Control Panel, clicking System and Security, and then clicking Power Options.
    On the Select a power plan page, click Change plan settings for the plan that you want to change.
    On the Change settings for the plan page, click Change advanced power settings.
    On the Advanced settings tab, expand Sleep, expand Allow wake timers, choose Disable for both when your computer is running on battery and when it's plugged in, and then click OK.

All our computers run a nightly backup job in the wee hours, to save data to a NAS drive. So I didn't disable the wake timers, as we need the backup tasks to wake up and run.

Similarly to the above, the power plan can be set so the computer will automatically go to sleep after some set minutes of idleness. If only this worked as well for my monkey mind.. but I wander. The problem now is sometimes it doesn't go back to sleep after running the backups.

To fix this, run the horrible new Windows 7 Event Viewer. Start, Control Panel, Administrative Tools, Event Viewer. Wait patiently for the immense gobs of .NET code to load and initialize. Then expand Windows Logs, select system, on RHS select 'Filter Current Log', pick 'Event Sources', pick 'Power Troubleshooter' to show all the wake events and their causes. Scroll through these to look for culprits.



Or, use the powercfg again:
powercfg -waketimers
shows everything with a wakeup,
powercfg -requests
shows what's keeping it up at night.
In this case,
DISPLAY:
None.
SYSTEM:
[DRIVER] \FileSystem\srvnet
An active remote client has recently sent requests to this machine.
AWAYMODE:
None.

There should not be any remote clients for this machine.
Who is out there requesting things I cannot deliver ?
Trolling through the dismal swamps of online forums suggests:
- Go to Services and disable "Windows Media Player Network Sharing Service".
Disabled, no change.
- Start, Control Panel, Network and Internet, Network and Sharing Center, Advanced sharing settings
Check under media streaming to block all sharing.
Nope, that wasn't it either.
- look for the Server service. I do loathe it when Windows names its services with these multivalent signifiers, so they look more like infections than reputable services. Apparently the Server service serves up a delectable dish of heaven-knows-what from my computer to random queries from heaven-knows-where. I can't think of a good reason for it to do that. Start, Control Panel, Administrative Tools, Services, locate the Server service, rightclick and disable.

Now at least my PC has quiet nights. With Windows 8.1 you are back on your own, have not attempted to debug its insomnia. Time for my tryptophan.. 

Update for Windows 10: 
all of the above still works. 
There's a new cause for failing to sleep, though. 

powercfg -requests 
shows 
EXECUTION:
[PROCESS] \Device\HarddiskVolume2\Windows\System32\MoUsoCoreWorker.exe 

This is the windows update service, running constantly in case I want to install optional updates. It's a bug introduced in Windows 10 fixes of April 2020 and again in September 2020. 
Stop and restart Windows Update Service which may work temporarily. Or, go and install the optional updates. At some point another Windows fix might resolve this, we live in hope. 

Update for Windows 10 in 2023: 
all the above still works. 
Newest caffeine pill for Windoze, no doubt introduced by yet another botched Windows fix - 

powercfg -LASTWAKE 
Owner Supplied Reason: Windows will execute 'NT TASK\Microsoft\Windows\Media Center\mcupdate_scheduled' scheduled task that requested waking the computer.

Start taskschd.msc from a Command prompt run as administrator. 
In the left pane of Task Scheduler, expand Task Scheduler Library, Microsoft, Windows, click on Media Center. 
In the middle pane, right click on mcupdate and select Properties. 
Go to Triggers tab and delete or disable all triggers. 
Go to Conditions tab and uncheck box for 'wake computer to run this task'. 
Go to Settings and uncheck all boxes related to starting. Leave the boxes for stopping the task and forcing the stop checked. 

Also go to Control Panel\All Control Panel Items\Power Options\Edit Plan Settings
Pick Advanced, expand the Multimedia, set When Sharing Media to 'Allow the computer to sleep' 



A poem by Charles Bukowski, for the ancestor of my Intel chip.

16-bit Intel 8088 chip

with an Apple Macintosh
you can't run Radio Shack programs
in its disc drive.
nor can a Commodore 64
drive read a file
you have created on an
IBM Personal Computer.
both Kaypro and Osborne computers use
the CP/M operating system
but can't read each other's
handwriting
for they format (write
on) discs in different
ways.
the Tandy 2000 runs MS-DOS but
can't use most programs produced for
the IBM Personal Computer
unless certain
bits and bytes are
altered
but the wind still blows over
Savannah
and in the Spring
the turkey buzzard struts and
flounces before his
hens.

No comments: