[Patch] regtool: Add load/unload commands and --binary option

Christian Franke Christian.Franke@t-online.de
Tue Jan 24 20:01:00 GMT 2006


Hi,

the attached patch adds commands "load" and "unload" and options "-b, 
--binary" to regtool.

Load a registry hive from PATH into new SUBKEY:

 regtool load KEY\SUBKEY PATH

Unload and remove SUBKEY later:

 regtool unload KEY\SUBKEY

Print REG_BINARY value as hex:

 regtool -b get KEY\VALUE

Set REG_BINARY value from hex args:

 regtool -b set KEY\VALUE XX XX XX XX ...


Example:
Suppose S:\ is a partition on a second HD which contains a copy of all 
files of XP system partition C:\.
The following script fixes the logical drive mappings of the backup 
installation.
This allows booting backup drive S:\ as C:\ after original C:\ drive has 
been removed.

#!/bin/sh
set -e

# Load backup SYSTEM hive as SYSTEM.TMP
regtool load /HKLM/SYSTEM.TMP /cygdrive/s/WINDOWS/system32/config/system
trap 'regtool unload /HKLM/SYSTEM.TMP' ERR

# Remove all logical drive mappings in backup
# (Somewhat tricky, because key value names contain backslashes)
for v in $(regtool list /HKLM/SYSTEM.TMP/MountedDevices |
          sed -n '/^\\DosDevices\\[C-Z]:$/s,\\,/,gp')
do
  regtool -K, unset "/HKLM/SYSTEM.TMP/MountedDevices,$v"
done

# Map current S:\ as C:\ in backup
m=$(regtool -K, -b get /HKLM/SYSTEM/MountedDevices/,/DosDevices/S:)
regtool -K, -b set /HKLM/SYSTEM.TMP/MountedDevices/,/DosDevices/C: $m

# Unload hive
trap '' ERR
regtool unload /HKLM/SYSTEM.TMP

# End of script
####################


Thanks for any comment

Christian

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: regtool-load-patch.txt
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20060124/4a8eb857/attachment.txt>


More information about the Cygwin-patches mailing list