Skip to content

Instantly share code, notes, and snippets.

@vincepare
Created December 11, 2015 00:09
Show Gist options
  • Save vincepare/5978b651f00895be3e77 to your computer and use it in GitHub Desktop.
Save vincepare/5978b651f00895be3e77 to your computer and use it in GitHub Desktop.
Automatic Windows registry dump batch script - export multiple reg keys at once (useful for backups)
:: Windows registry dump batch script
:: Copyright (c) 2015 Vincent Paré
:: Licensed under the Apache 2.0 license : http://opensource.org/licenses/Apache-2.0
@echo off
pushd %~dp0
echo Export directory : %CD%
:: Get current timestamp
set hour=%time:~0,2%
if "%hour:~0,1%" == " " set hour=0%hour:~1,1%
set min=%time:~3,2%
if "%min:~0,1%" == " " set min=0%min:~1,1%
set secs=%time:~6,2%
if "%secs:~0,1%" == " " set secs=0%secs:~1,1%
set year=%date:~-4%
set month=%date:~3,2%
if "%month:~0,1%" == " " set month=0%month:~1,1%
set day=%date:~0,2%
if "%day:~0,1%" == " " set day=0%day:~1,1%
set datetimef=%year%-%month%-%day%_%hour%h%min%m%secs%
:: Registry keys to dump
call:dumpRegKey "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
call:dumpRegKey "HKEY_CURRENT_USER\Software\WinRAR"
call:dumpRegKey "HKEY_CURRENT_USER\Software\SimonTatham"
call:dumpRegKey "HKEY_CURRENT_USER\Software\Telerik\Fiddler"
call:dumpRegKey "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fiddler2"
pause
popd
goto:eof
:: Key dump function
:dumpRegKey
set key=%~1
set cleankey=%key:\= %
echo %key%
reg export "%key%" "registryDump %datetimef% %cleankey%.reg.ini"
echo.
ping -n 2 127.0.0.1 >nul
goto:eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment