Tag Archives: powercfg

150x100_windows

Prevent Vista entering standby when running O&O Defrag


O&O Defrag doesn’t prevent the computer from entering sleep/standby/hibernate whilst in use. This has caused an issue in the past of a corrupted drive.

This work around should prevent the PC from entering sleep whilst O&O Defrag runs a scheduled job.


Summary: Create a new power plan in Vista that doesn’t put the computer to sleep. Use the command-line utility PowerCFG and O&O Defrag’s pre / post commands to switch to and from the new power plan when defragmenting.


1. Press the Start button, type “Power Options”, and press Enter.

2. In the Power Options dialog, click “Create a power plan” on the left.

prevent-vista-entering-standby-when-running-oo-defrag-image1

3. Select “High Performance” as the plan to base the new one on, and give this plan the name of “Defrag”. Click Next.

prevent-vista-entering-standby-when-running-oo-defrag-image2

4. Choose “Never” for the option “Put the computer to sleep” and click Create.

5. Open a command prompt (press Start, type “cmd” and press enter).

prevent-vista-entering-standby-when-running-oo-defrag-image3

6. Type “powercfg /list” at the command prompt and press enter.

7. Each scheme has a unique GUID. Note which GUID is the currently active one (noted with an asterisk *). In the example the GUID for “Workstation” is the active one. Also note the new “Defrag” scheme and its GUID. We use these GUID’s to switch power scheme in O&O Defrag.

prevent-vista-entering-standby-when-running-oo-defrag-image4

8. Open O&O Defrag, find the Job list with your scheduled task. In O&O Defrag 11 the “Jobs” tab is at the bottom of the screen.

prevent-vista-entering-standby-when-running-oo-defrag-image5

9. Create a new task, or edit an existing one.

10. Under the tab, “Pre-Job Execution”, tick the box “Run the following commands before job execution”.

11. In the text area underneath you need to add the command to set the active power scheme to the new one we just made. The command syntax is powercfg -setactive <GUID>, where you need the GUID of the new power scheme as found earlier. In the example, you can see another powercfg command, this is explained in an earlier post.

prevent-vista-entering-standby-when-running-oo-defrag-image6

12. Select the tab “Post-Job Execution” and tick the box for “Run the following commands after job execution”. Then put in the same command as before, but instead, use the GUID for your currently active power scheme, as found earlier.

prevent-vista-entering-standby-when-running-oo-defrag-image7

13. Click OK and you’re done! When this job begins, the power scheme with Sleep disabled will be made active, and then once completed, it shall activate the original power scheme.


Using this workaround you prevent your computer from going to sleep during defrag, so you can leave the PC safe inthe knowledge that it will complete its defrag, and then put itself to sleep shortly after.

150x100_windows

Disable hibernation during O&O Defrag job


If you have hibernation enabled in Windows Vista, then there will be a file at C:hiberfil.sys which is the same size as the amount of ram in your computer. This file is locked and cannot be defragmented.

You can automatically and temporarily disable hibernation and remove the hiberfil.sys for the duration of the defrag. In my case this unlocks 4GB of space on the system drive.

Create a new job, or edit an existing job in O&O Defrag and under “Pre-Job Execution” tick the “Run the following commands…” box, and in the text area underneath put:
powercfg -h off
And then under the tab for “Post-Job Execution” tick the same box, “Run the following commands…”, and in the text area underneath put:
powercfg -h on