Skip to main content

How to Create a System Restore Point in Batch Script

Creating a System Restore Point is a critical safety measure before performing major software installations, registry edits, driver updates, or system configuration changes. A restore point captures a snapshot of Windows system files, program files, and registry settings that can be used to roll back to a known-good state if something goes wrong. Automating this with a Batch script provides a reliable "one-click" safety net that can be integrated into maintenance workflows.

This guide explains how to create, verify, and manage System Restore Points programmatically.

How System Restore Works

System Restore Point:

  • A snapshot of important system components, including:

    • Windows system files
    • Installed programs
    • Registry settings
    • System drivers
  • The snapshot does not include:

    • Personal files (documents, photos, videos, etc.)
    • Files stored in user folders (such as Desktop, Documents, Downloads)
    • Data on drives where System Protection is not enabled
  • How it works:

    • Uses the Volume Shadow Copy Service (VSS)
    • Creates differential snapshots, meaning it only stores changes rather than full copies of files
Administrative Privileges Required

Creating a restore point is a system-wide operation managed by the Volume Shadow Copy service. The script MUST be run as Administrator. Without elevation, the Checkpoint-Computer command is silently rejected.

Restore Point Types:

TypeWhen to Use
MODIFY_SETTINGSBefore system configuration changes, registry edits, hosts file modifications
APPLICATION_INSTALLBefore software installation
APPLICATION_UNINSTALLBefore software removal
DEVICE_DRIVER_INSTALLBefore driver updates or hardware changes

Method 1: Create a Restore Point with Full Validation

This method checks all prerequisites, handles the 24-hour creation limit, and verifies the restore point was actually created.

@echo off
setlocal EnableDelayedExpansion

set "Description=%~1"
set "RPType=MODIFY_SETTINGS"

if "%Description%"=="" (
:: Generate a default description with timestamp
for /f "delims=" %%t in (
'powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd"'
) do set "Description=Manual Restore Point %%t"
)

if not "%~2"=="" set "RPType=%~2"

echo ============================================================
echo System Restore Point Creator
echo ============================================================
echo.

:: =============================================
:: Step 1: Check admin privileges
:: =============================================
net session >nul 2>&1
if errorlevel 1 (
echo [ERROR] This script must be run as Administrator. >&2
echo Right-click and select "Run as administrator." >&2
endlocal
exit /b 1
)

echo [OK] Running with administrator privileges.

:: =============================================
:: Step 2: Check if System Restore is enabled
:: =============================================
echo [INFO] Checking System Restore status...

for /f "delims=" %%s in (
'powershell -NoProfile -Command "try { $null = Get-ComputerRestorePoint -ErrorAction Stop } catch { Write-Output DISABLED; exit }; Write-Output ENABLED"'
) do set "RestoreStatus=%%s"

if "%RestoreStatus%"=="DISABLED" (
echo [ERROR] System Restore is DISABLED on this system. >&2
echo. >&2
echo To enable System Restore: >&2
echo 1. Open System Properties (sysdm.cpl^) >&2
echo 2. Go to the System Protection tab >&2
echo 3. Select the C: drive and click Configure >&2
echo 4. Select "Turn on system protection" >&2
echo. >&2
echo Or enable via script: >&2
echo powershell -Command "Enable-ComputerRestore -Drive 'C:\'" >&2
endlocal
exit /b 1
)

echo [OK] System Restore is enabled.

:: =============================================
:: Step 3: Check disk space
:: =============================================
echo [INFO] Checking disk space...

for /f "delims=" %%f in (
'powershell -NoProfile -Command "[math]::Round((Get-CimInstance Win32_LogicalDisk | Where-Object DeviceID -eq C:).FreeSpace / 1GB, 1)"'
) do set "FreeGB=%%f"

powershell -NoProfile -Command "if (%FreeGB% -lt 1) { exit 1 } else { exit 0 }" >nul 2>&1
if errorlevel 1 (
echo [WARNING] Very low disk space (%FreeGB% GB free^). >&2
echo The restore point may fail or consume remaining space. >&2
echo.
set /p "Continue=Continue anyway? (YES/no): "
if /i not "!Continue!"=="YES" (
echo [INFO] Cancelled.
endlocal
exit /b 0
)
) else (
echo [OK] Disk space: %FreeGB% GB free.
)

:: =============================================
:: Step 4: Get current restore point count (for verification)
:: =============================================
for /f "delims=" %%n in (
'powershell -NoProfile -Command "@(Get-ComputerRestorePoint -ErrorAction SilentlyContinue).Count"'
) do set "BeforeCount=%%n"

:: =============================================
:: Step 5: Create the restore point
:: =============================================
echo.
echo [ACTION] Creating restore point...
echo Description: %Description%
echo Type: %RPType%
echo This typically takes 15-60 seconds. Please wait...
echo.

powershell -NoProfile -ExecutionPolicy Bypass -Command "try { Checkpoint-Computer -Description '%Description%' -RestorePointType '%RPType%' -ErrorAction Stop; exit 0 } catch { Write-Error $_.Exception.Message; exit 1 }"

set "CreateResult=!errorlevel!"

:: =============================================
:: Step 6: Verify creation
:: =============================================
if %CreateResult% neq 0 (
echo [ERROR] Failed to create restore point. >&2
echo. >&2
echo Common causes: >&2
echo - Another restore point was created in the last 24 hours >&2
echo (Windows limits automatic creation frequency^) >&2
echo - Insufficient disk space for the snapshot >&2
echo - Volume Shadow Copy service is not running >&2
echo - System Restore is disabled for the C: drive >&2
endlocal
exit /b 1
)

:: Verify the count increased
for /f "delims=" %%n in (
'powershell -NoProfile -Command "@(Get-ComputerRestorePoint -ErrorAction SilentlyContinue).Count"'
) do set "AfterCount=%%n"

if %AfterCount% gtr %BeforeCount% (
echo [OK] Restore point created successfully.
echo.

:: Show the new restore point details
echo [INFO] Latest restore point:
powershell -NoProfile -Command "$rp = Get-ComputerRestorePoint | Select-Object -Last 1; Write-Host (' Sequence: ' + $rp.SequenceNumber); Write-Host (' Description: ' + $rp.Description); Write-Host (' Created: ' + $rp.ConvertToDateTime($rp.CreationTime))"
) else (
echo [WARNING] Command completed but no new restore point appears. >&2
echo This may be due to the 24-hour creation limit. >&2
echo.
echo [INFO] Most recent existing restore point:
powershell -NoProfile -Command "$rp = Get-ComputerRestorePoint | Select-Object -Last 1; Write-Host (' Description: ' + $rp.Description); Write-Host (' Created: ' + $rp.ConvertToDateTime($rp.CreationTime))"
)

echo.
echo ============================================================
echo Operation complete.
echo ============================================================

endlocal
exit /b 0

The 24-hour creation limit:

Windows 24-Hour Limit

By default, Windows limits scripted restore point creation to once every 24 hours. If Checkpoint-Computer is called within 24 hours of the previous restore point, it returns success (exit code 0) but does NOT create a new restore point. This is a silent no-op.

The script detects this by comparing the restore point count before and after the Checkpoint-Computer call. If the count didn't increase, the 24-hour limit likely blocked creation.

To bypass this limit (useful for development/testing environments), set the following registry key:

reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" ^
/v SystemRestorePointCreationFrequency /t REG_DWORD /d 0 /f

Setting the value to 0 allows unlimited creation frequency. This is generally NOT recommended for production systems, as frequent restore points consume significant disk space.

Why -ExecutionPolicy Bypass:

PowerShell may be configured to block scripts via its Execution Policy. Since Checkpoint-Computer is a cmdlet (not a script file), it normally works regardless of the policy. However, -ExecutionPolicy Bypass ensures the command runs in all environments, including locked-down enterprise configurations. This flag only affects the current PowerShell session: it does not change the system-wide policy.

Method 2: Pre-Maintenance Guard (Integrated Safety Net)

Use this pattern at the beginning of any maintenance script that makes system changes. It creates a restore point as a mandatory first step.

@echo off
setlocal EnableDelayedExpansion

echo [GUARD] Creating safety restore point before maintenance...

:: =============================================
:: Create restore point (required before proceeding)
:: =============================================
call :CreateRestorePoint "Before Maintenance Script %date%"
if errorlevel 1 (
echo [WARNING] Could not create restore point. >&2
echo.
set /p "Proceed=Proceed WITHOUT a restore point? (YES/no): "
if /i not "!Proceed!"=="YES" (
echo [ABORT] Maintenance cancelled.
endlocal
exit /b 1
)
echo [WARNING] Proceeding without safety net. >&2
)

echo.

:: =============================================
:: Your maintenance code here
:: =============================================
echo [INFO] Performing maintenance tasks...

:: Example: Install a driver
:: pnputil /add-driver "C:\Drivers\network.inf" /install

:: Example: Registry modification
:: reg add "HKLM\SOFTWARE\MyApp" /v Setting1 /t REG_SZ /d "Value" /f

:: Example: System configuration change
:: bcdedit /set testsigning on

echo [OK] Maintenance complete.

echo.
echo [INFO] If something went wrong, restore from:
echo System Properties ^> System Protection ^> System Restore

endlocal
exit /b 0


:: =============================================
:: Restore Point Subroutine
:: =============================================
:CreateRestorePoint
net session >nul 2>&1
if errorlevel 1 (
echo [ERROR] Admin rights required for restore points. >&2
exit /b 1
)

powershell -NoProfile -ExecutionPolicy Bypass -Command "try { Checkpoint-Computer -Description '%~1' -RestorePointType 'MODIFY_SETTINGS' -ErrorAction Stop; exit 0 } catch { exit 1 }" >nul 2>&1

if errorlevel 1 (
echo [WARNING] Restore point creation failed.
exit /b 1
)

echo [OK] Restore point created: %~1
exit /b 0

Why the guard allows proceeding without a restore point:

In some scenarios (24-hour limit, System Restore disabled, low disk space), creating a restore point is impossible. The script warns but allows the administrator to make an informed decision about proceeding. This is better than silently skipping the safety step or aborting when the maintenance is urgently needed.

Method 3: Enable System Restore and Create a Point

On some systems, particularly fresh installations, virtual machines, or systems configured by Group Policy, System Restore may be disabled. This method enables it before creating the restore point.

@echo off
setlocal

net session >nul 2>&1
if errorlevel 1 (
echo [ERROR] Administrator privileges required. >&2
endlocal
exit /b 1
)

echo [INFO] Ensuring System Restore is enabled on C:\...

:: Enable System Restore for the C: drive
powershell -NoProfile -Command "try { Enable-ComputerRestore -Drive 'C:\' -ErrorAction Stop; Write-Host '[OK] System Restore enabled for C:\'; exit 0 } catch { Write-Error $_.Exception.Message; exit 1 }"

if errorlevel 1 (
echo [ERROR] Could not enable System Restore. >&2
echo This may be blocked by Group Policy or the Volume Shadow Copy service. >&2
endlocal
exit /b 1
)

:: Verify the Volume Shadow Copy service is running
sc query vss | findstr /i "RUNNING" >nul 2>&1
if errorlevel 1 (
echo [INFO] Starting Volume Shadow Copy service...
net start vss >nul 2>&1
)

:: Create the restore point
echo [ACTION] Creating restore point...
powershell -NoProfile -ExecutionPolicy Bypass -Command "Checkpoint-Computer -Description 'System Protection Enabled' -RestorePointType 'MODIFY_SETTINGS' -ErrorAction SilentlyContinue"

echo [OK] System Restore is configured and a restore point has been created.

endlocal
exit /b 0
System Restore Disk Space

System Restore uses a percentage of the drive for storing snapshots (typically 5–10%, configurable in System Properties). On a 500 GB drive, this means 25–50 GB dedicated to restore points. If disk space is critically low, consider reducing the allocation:

vssadmin resize shadowstorage /for=C: /on=C: /maxsize=5GB

Method 4: List and Verify Existing Restore Points

View all available restore points to verify creation or identify which point to restore to.

@echo off
setlocal

echo [INFO] Available System Restore Points:
echo --------------------------------------------------
echo.

powershell -NoProfile -Command "$rps = Get-ComputerRestorePoint -ErrorAction SilentlyContinue; if (-not $rps) { Write-Host ' No restore points found.'; Write-Host ' System Restore may be disabled or no points have been created.'; exit 0 }; $rps | ForEach-Object { $created = $_.ConvertToDateTime($_.CreationTime); $type = switch ($_.RestorePointType) { 0 {'Application Install'} 1 {'Application Uninstall'} 6 {'System Restore'} 7 {'Windows Update'} 10 {'Device Driver'} 12 {'Modify Settings'} 13 {'Cancelled Operation'} default {'Other'} }; [PSCustomObject]@{ '#' = $_.SequenceNumber; 'Created' = $created.ToString('yyyy-MM-dd HH:mm'); 'Type' = $type; 'Description' = $_.Description } } | Format-Table -AutoSize -Wrap"

echo --------------------------------------------------

endlocal
exit /b 0

How to Avoid Common Errors

Wrong Way: Not Checking if System Restore Is Enabled

:: Fails silently on systems with System Restore disabled
powershell Checkpoint-Computer -Description "My Point"
:: Returns success (exit 0) but no restore point is created

On systems where System Restore is disabled (VMs, freshly imaged machines, Group Policy restrictions), Checkpoint-Computer may return success without creating anything.

Correct Way: Check System Restore status before attempting creation (Method 1), or enable it first (Method 3).

Wrong Way: Ignoring the 24-Hour Limit

:: Appears to succeed but creates nothing if run twice in 24 hours
powershell Checkpoint-Computer -Description "Point 1"
:: (some work)
powershell Checkpoint-Computer -Description "Point 2"
:: Point 2 is silently NOT created

Correct Way: Method 1 detects the limit by comparing restore point counts before and after. If the count didn't increase, the script warns about the 24-hour restriction.

Problem: Volume Shadow Copy Service Not Running

Checkpoint-Computer depends on the Volume Shadow Copy (VSS) service. If it's stopped or disabled, creation fails.

Solution: Method 3 checks and starts the service. For a quick manual check:

sc query vss | findstr /i "RUNNING"

Problem: Not Enough Disk Space

System Restore requires significant disk space for snapshots. If the drive is nearly full, creation fails or the snapshot is immediately discarded.

Solution: Method 1 checks free space and warns below 1 GB. For critically low space, consider reducing the System Restore allocation:

vssadmin resize shadowstorage /for=C: /on=C: /maxsize=3GB

Problem: Locale-Dependent Timestamp in Description

:: GARBLED on non-US systems
set "RP_NAME=BeforeMaintenance_%date:~-4%%date:~4,2%%date:~7,2%"

Correct Way: Use PowerShell for locale-independent timestamps:

for /f "delims=" %%t in (
'powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd"'
) do set "Description=Manual Restore Point %%t"

Best Practices and Rules

1. Create a Restore Point Before Any Major Change

Driver installations, registry modifications, system configuration changes, and Group Policy edits should all be preceded by a restore point. Method 2's guard pattern makes this automatic.

2. Use Descriptive Names

Include what the restore point is for: "Before Driver Update 2024-05-10", "Pre-Registry Cleanup", "Before BIOS Update". Generic names like "My Point" are useless when choosing which point to restore to.

3. Verify Creation - Don't Trust the Exit Code

Checkpoint-Computer returns 0 even when the 24-hour limit prevents creation. Always verify by checking the restore point count or listing points (Method 4).

4. Integrate into Maintenance Workflows

Don't create restore points as a separate manual step, embed them into your maintenance scripts (Method 2) so they happen automatically.

5. Monitor Disk Space for System Restore

System Restore snapshots consume disk space. On systems with limited storage, old restore points may be automatically purged when space runs out, potentially removing your safety net. Monitor and configure the allocation size appropriately.

6. Remember: Restore Points Don't Replace Backups

System Restore captures system files and settings but NOT personal files, databases, or data on non-protected drives. For complete protection, combine restore points with proper file/image backups.

Conclusion

Creating System Restore Points via Batch script provides an automated safety net for any maintenance operation that changes system configuration. By checking prerequisites (admin rights, System Restore enabled, disk space, VSS service), handling the 24-hour creation limit, verifying the restore point was actually created, and integrating the creation step into maintenance workflows, you ensure that every major system change has a reliable rollback option.