U-Tools: Unique Tools for Windows System Administrators
U-Recover Help
Menu

Running scripts using Group Policy

You can use U-Recover Pro to design Group Policy scripts that control how volume snapshots and restore points are created by your desktop PCs. This gives you for fine-grained control over exactly how and when volume snapshots and restore points are created by the member computers in your organization's Active Directory domain.

Example: How to create a Group Policy script for setting up your desktop PCs to create daily snapshots and weekly restore points

This example shows you how to create a computer startup script in Group Policy that will configure desktop computer to make daily volume snapshots at 7:15 every morning and set weekly restore points. at 3:15 every Sunday night.

The Group Policy script shown below will do the following operations at boot time:

  • Allocate 50 GB of space on C: for volume snapshots and restore points (if not already allocated).
  • Create a daily scheduled task for taking snapshots of C: (if not already set)
  • Create a weekly scheduled task for setting restore points (if not already set).
Step 1: Create the XML scripts

Create the XML script MakeVolumeSchedTask.xml. See Create a daily scheduled task for taking snapshots of C:.

Create the XML script MakeSysProtTask.xml. See Create a weekly scheduled task for setting restore points.

Step 2: Create the Group Policy script

Create a file called PrepSchedSnapshotTasks.cmd that contains the following:

rem
rem Check if C: has space reserved for volume snapshots
rem and restore points.
rem
vssadmin list shadowstorage /For=C: | findstr /L "Allocated" >NUL 2>>&1
if ERRORLEVEL 1 goto NoShadowStorage
goto CheckTasks
:NoShadowStorage
rem
rem Allocate 50 gigabytes for volume snapshots and restore points.
rem
vssadmin resize shadowstorage /For=C: /On=C: /Size=50GB
:CheckTasks
schtasks.exe /Query | findstr /L /I "URecover Volume" >NUL
if ERRORLEVEL 1 goto NoVolumeTask
goto CheckRestorePoints
:NoVolumeTask
rem
rem Create a scheduled task to make daily volume snapshots of C:
rem
cd /d "C:\Program Files\URecover"
start "URecover" /wait .\URecover.exe -xml MakeVolumeSchedTask.xml
rem
rem Check if the URecover System Protection Task was
rem already created.
rem
:CheckSysProtTask
schtasks.exe /Query /TN "URecover System Protection" >NUL 2>&1
if ERRORLEVEL 1 goto NoSysProtTask
goto Done
rem
rem Create a schedled task to set weekly restore points
rem
:NoSysProtTask
cd /d "C:\Program Files\URecover"
start "URecover" /wait .\URecover.exe -xml MakeSysProtTask.xml
:Done
exit /b 0

Copy the above text into file named PrepSchedSnapshotTasks.cmd to the Netlogon shared folder on the domain controller.

Step 3: Assign the Computer Startup Script to a Group Policy Object

Assign the script to the Group Policy Object.

See Assign Computer Startup Scripts (Microsoft Docs).