Saturday, August 04, 2018

Scheduling Automatic Restore Point Creation in Windows 10

It's been some time. I am alive and well and living in San Antonio, TX, as I have since January 2018. The cats are fine. I start a new contract job next week. I am excited to do that. Been driving Uber to keep busy in between catching up on Java stuff. Java 8 has been out awhile now and we're up to 10. I am fine with most stuff between 8 and 10 except for the new "var" support. This is against the strongly-typed paradigm that Java was built on. The paint began coming off the walls when Generics were introduced but that was really not so bad. This use of "var" now in methods to create auto-typed variables is really not good. But anyway, this post is about scheduling the creation of a restore point automatically in Windows 10 so I will get back on subject.

Restore points are used to help restore the OS to its prior state when an install goes bad. It is mostly a defense against badly-written drivers getting installed into your system. It is a good practice though to run the restore point creation function regularly. It can be kicked off by hand or by command. Since commands can be scheduled, it can be set up to do this daily or weekly (I recommend daily) automatically vs. by hand. There are directions out there on the web re how to do this but there are preconditions and pitfalls that are gotchyas for people unfamiliar with how sneaky Windows can be. So this post is a start-to-finish guide for Windows 10 users on how to schedule daily restore point creation.

1. Make sure you have permission to create restore points. You need to have Admin on the machine. If not, it won't work. Further, it needs to be enabled. To do this right-click on "This PC" on the desktop and click "Properties". Click "System Protection" and then "Configure", then make sure "Turn on system protection" is selected. Next under "Disk Space Usage" make sure you set it to 5%. That should be quite sufficient for your needs. Then click "OK". Then, "OK" again to close the original dialog.

2. Win 10 by default does not allow the user to create more than one restore point manually per day. This is crazy. But it can be fixed. To do this, download the Winaero Tweaker currently at https://winaero.com/download.php?view.1796. Install it. Then open it and type "restore" in the search box at the upper left. "System Restore Point Frequency" appears. Dbl-click it. There is a single checkbox on the form that comes up. Check it. Then choose File...Exit (No "Save" is needed.). [BTW, this utility has a load of tweaks you can apply. Be careful however because some have system-wide repercussions. If you use the utility for other tweaks, do so carefully.] What you just did could be done w/out the utility but it would require going through all manner of manual steps including hacking the hive. I wanted to avoid that.

3. Finally it's time to schedule the restore point creation. In the Windows Search Box (the "Cortana" box), type "schedule tasks" and open the control panel that comes up by dbl-clicking on it. At the right, you see "Create Task...". Click it. Fill in values as follows:

In the "General" tab:
a. Name: Pick a name, any name. Try "Daily restore point".
b. Click "Run whether user is logged on or not".
c. Check "Run with the highest privileges".


In the "Triggers" tab:
a. Click "New...".
b. Click "Daily" under "Settings".
c. Next to "Start:" is the current date. Next to the date is the current time. Set the time for 20 minutes from now.
d. Check "Stop task if it runs longer than" and select "30 minutes".
e. Click "OK".

In the "Actions" tab:
a. Click "New...".
b. In "Program/Script", specify: powershell.exe
c. In "Add arguments (optional)", specify: -ExecutionPolicy Bypass -Command "Checkpoint-Computer -Description \"Restore Point (Automatic)\" -RestorePointType \"MODIFY_SETTINGS\""
d. In "Start in (optional)", specify: C:\WINDOWS\system32

I recommend you copy and paste the above commands into the interface to avoid typos.

e. Click "OK".

In the "Conditions" tab:
a. Under "Power", choose what you want. In my case I have it so it runs only if the laptop is on AC power and it stops if it switches to battery. But this is up to you.

In the "Settings" tab:
a. Check"Allow task to be run on demand".
b. Check "Stop the task if it runs longer than:" then select "1 hour".
c. Check "If the running task does not end when requested, force it to stop".
d. Click "OK". You should get a password challenge. Indicate your password and then the task gets created.

A bug in Windows that has been around for some time makes it so that not all newly-created tasks are immediately viewable. If you don't see your new task in the list of tasks, choose File...Exit in the Task Scheduler then re-start Windows. Yes I know this is dumb. But what can you do.

When Windows re-starts, simply wait until the time comes that you indicated in step c under "Triggers" above. Then wait five minutes past that point since creating a new point can take that long especially if one was not created recently.

Now to check to see if your point was made, right-click on "This PC" on the desktop and click "Properties". Click "System Protection" and then "System Restore...", then "Next". In the list of restore points it should have as the most recent point one created just a few mins. ago. Click "Cancel", then close the "System Properties" by clicking "Cancel", then close the "System" panel.

Now that the point is known to be working, you need to schedule it to run when you actually want it to run. If you are fine with the current time, then you need do nothing else. If however like me you want it to run at, say, 3:00 AM, do as follows:

1. In the Windows Search Box (the "Cortana" box), types "schedule tasks" and open the control panel that comes up.
2. Under "Active tasks", locate your newly-created task. If it does not appear, click "Refresh".
3. Once located, double-click on it.
4. In the list at the top, the task is selected. Double-click on that selected item. You are now in task edit mode.
5. Click the "Triggers" tab.
6. Click "Edit..."
7. Edit the time to be what you want it to be.
8. Click "OK".
9. Click "OK". At step 8 or 9 you should get a password challenge. Supply your password.
10. Choose File...Exit to close the Task Scheduler.

After the next time the task is expected to run, check to see if it was indeed created. Right-click on "This PC" on the desktop and click "Properties". Click "System Protection" and then "System Restore...", then "Next". In the list of restore points it should have as the most recent point created. Click "Cancel", then close the "System Properties" by clicking "Cancel", then close the "System" panel.

I hope this helps folks with this task. Getting all the correct details together for Win 10 can be a pain.