In my last post on this topic, I described a couple of scenarios in which your PC would not automatically sleep. I’ve got good news to report on both.
Streaming Web Video
The first is our old friend Adobe Flash. I’ve been working with the Adobe on this issue for some time now, and with some help from a well known environmental NGO and a large user of Flash, the great news is that it appears that most of the issues are now fixed with the current beta 3 release of Flash 10.1. Before you all rush to go and download it there are a few things you should know.
First the good news (yes there’s a catch). Flash 10.1b3 now appears to close the audio channel when a streaming video ends or is paused. This is important because previous versions of Flash streamed silence to the audio stack, which in turn prevented Windows from automatically putting the PC to sleep. Additionally, when viewing Flash videos full screen, Flash prevents the screen from dimming or blanking, which is great if you are sitting back and watching the screen. It will not prevent dimming if you do not put the viewer in full screen mode. I’m guessing that most folks watch short videos in non-full screen mode, so dimming may still be an issue for some.
The bad news (for now) is that Flash changes the timer resolution down to 1ms as soon as a web page loads it. What this means is that it uses more power than it needs to and in particular will drain your battery faster. (I’ve heard up to 20% faster but have not confirmed this with my own measurements). However, I’ve been assured that this is a temporary situation and that Flash will revert back to it’s old 10.0 behavior in this regard for the final release (it’s there just for the beta I’m told).
So, my advice is that if you have a desktop or a laptop that spends most of its life plugged into the wall, its probably better to install 10.1b3 so automatic sleep has a chance to work more often (keep in mind that this is a beta, and you may run into other non-desirable issues).
If you run on battery a lot and frequently browse the web, you might want to think twice about installing 10.1 until it’s officially released. Unfortunately I have no idea when that will be, but I’m hoping it’s not too far out! Even if you don’t think you use Flash much while on battery, you’d be surprised how often sites cause it to load up just in case. Even MSN.com loads up Flash when you visit, even though it doesn’t appear to use it.
Open files across the network
After discovering that Microsoft Office PowerPoint and Excel seemed to keep files open across the network. which in turn prevented Windows from automatically sleeping, I started a thread with both the Office and Offline folders team. It turns out that there are two issues here, one that is getting fixed in Windows 7 SP1 and another that you can fix yourself.
The first problem was a bug in Offline folders (the files that PowerPoint and Excel were opening were mistakenly seen as ‘sparse’ but Offline folders, which prevented the machine from sleeping). This is great if you are using Offline Folders and deploy SP1 whenever that is ready, but what can you do about it now?
Well it so happens there is a workaround to this and I’ve been running it for several months to make sure there were no ill effects. It involves changing a Windows 7 power policy setting, and while quite effective is not particularly easy to change as it involves reading and writing multiple GUIDs. So I created a batch file which automatically changes the policy on the current active power plan (e.g. if you’re running the balanced plan and then run the batch file, the policy is changed for that power plan).
Before I get to the batch file which I will paste here, a little bit on what the policy does and what impact it has.
The policy is actually a hidden policy called “Allow Sleep with remote opens”. When enabled this allows the PC to automatically sleep even when files are open read-only across the network. Unless PowerPoint or Excel is actively writing a file, the file is open read-only the rest of the time.
The side effect of this policy is that if you computer goes to sleep when you have a PPT or XLS file open and you have made changes to it but not saved, then you will occasionally get a message from the application that the changes that were made have not been saved and that you should save the changes in a different file.
I used to occasionally see these messages before I changed this policy, so this isn’t really a big deal. Simply save the file as a new file and continue.
I’m hoping to have Microsoft IT run this policy against a large number of machines inside Microsoft to see if there are any other side effects. My hope is that if all turns out well that this becomes the default behavior for Windows 8. Until then, you can change the policy yourself and let me know what your experiences are. Keep in mind that the only files I typically have open across the network are opened by Microsoft applications, so I don’t know what it will do with other apps. Your mileage may vary and the standard legal disclaimer applies here.
Before you run the batch file to change the policy, open up a PowerPoint or Excel file across the network and do a ‘powercfg /requests (see my last “Insomnia” post for how to do that if necessary). You should see the open file blocking automatic sleep. Close the file and run the the batch file, and then open up the file again. You should see that the open file is not blocking automatic sleep anymore.
With that said, here’s the batch file. Copy and paste this into notepad, save it as a .cmd file (I call it cfopp.cmd) and then double click on it (make sure you don’t accidentally save it with a .txt extension on the end, its easy to do and of course it won’t run).
Note this is only tested on Windows 7. I have not tried this on Vista (not sure if the policy even exists on Vista). It definitely won’t work on XP. Also, my ‘success’ test is a little fragile, so do a powercfg /qh if you see the failure message and check to see if the “allow sleep with remote opens” policy is set to 1 or 0. If it’s set to 1, you’re all set.
Use the comments link to let me know how this works out for you.
REM CFOPP – Change File Open Power Policy
REM Change policy so automatic sleep can occur with remote file opens
if exist %ofile% del %ofile%
if exist %ofile% goto ERROR1
powercfg /l | find /v “Existing Power Schemes” | find “*” > %ofile%
for /f “delims=\(\) tokens=2” %%i in (%ofile%) do set currentpowerscheme=%%i
echo Changing current power policy (%currentpowerscheme%) to allow automatic sleep with remote opens…
powercfg /l | find “*” > %ofile%
for /f “tokens=4” %%i in (%ofile%) do set currentpowerschemeguid=%%i
powercfg /q | find “(Sleep)” > %ofile%
for /f “tokens=3” %%i in (%ofile%) do set sleepsubgroupguid=%%i
powercfg /qh | find “remote opens” > %ofile%
for /f “tokens=4” %%i in (%ofile%) do set remoteopenguid=%%i
Powercfg -setacvalueindex %currentpowerschemeguid% %sleepsubgroupguid% %remoteopenguid% 1
Powercfg -setdcvalueindex %currentpowerschemeguid% %sleepsubgroupguid% %remoteopenguid% 1
powercfg /qh %currentpowerschemeguid% %sleepsubgroupguid% | more +66 | find “0x00000001” >nul
if errorlevel 1 goto ERROR2
echo cannot delete %ofile%
TYPE NUL | choice /c:5 /td,10 >NUL
echo Cannot change policy (ensure adequate permissions)
REM Pause 3 seconds so user can see messages
CHOICE /T 3 /C ync /CS /D y >nul