virt-win-reg

Langue: en

Version: 2010-09-16 (fedora - 01/12/10)

Section: 1 (Commandes utilisateur)

NAME

virt-win-reg - Export and merge Windows Registry entries from a Windows guest

SYNOPSIS

  virt-win-reg domname 'HKLM\Path\To\Subkey'
 
  virt-win-reg domname 'HKLM\Path\To\Subkey' name
 
  virt-win-reg domname 'HKLM\Path\To\Subkey' @
 
  virt-win-reg --merge domname [input.reg ...]
 
  virt-win-reg [--options] disk.img ... # instead of domname
 
 

WARNING

You must not use "virt-win-reg" with the "--merge" option on live virtual machines. If you do this, you will get irreversible disk corruption in the VM. "virt-win-reg" tries to stop you from doing this, but doesn't catch all cases.

Modifying the Windows Registry is an inherently risky operation. The format is deliberately obscure and undocumented, and Registry changes can leave the system unbootable. Therefore when using the "--merge" option, make sure you have a reliable backup first.

DESCRIPTION

This program can export and merge Windows Registry entries from a Windows guest.

The first parameter is the libvirt guest name or the raw disk image of a Windows guest.

If "--merge" is not specified, then the chosen registry key is displayed/exported (recursively). For example:

  $ virt-win-reg Windows7 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft'
 
 

You can also display single values from within registry keys, for example:

  $ cvkey='HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
  $ virt-win-reg Windows7 $cvkey ProductName
  Windows 7 Enterprise
 
 

With "--merge", you can merge a textual regedit file into the Windows Registry:

  $ virt-win-reg --merge Windows7 changes.reg
 
 

SUPPORTED SYSTEMS

The program currently supports Windows NT-derived guests starting with Windows XP through to at least Windows 7.

Registry support is done for "HKEY_LOCAL_MACHINE\SAM", "HKEY_LOCAL_MACHINE\SECURITY", "HKEY_LOCAL_MACHINE\SOFTWARE", "HKEY_LOCAL_MACHINE\SYSTEM" and "HKEY_USERS\.DEFAULT".

You can use "HKLM" as a shorthand for "HKEY_LOCAL_MACHINE", and "HKU" for "HKEY_USERS".

"HKEY_USERS\$SID" and "HKEY_CURRENT_USER" are not supported at this time.

NOTE

This program is only meant for simple access to the registry. If you want to do complicated things with the registry, we suggest you download the Registry hive files from the guest using libguestfs(3) or guestfish(1) and access them locally, eg. using hivex(3), hivexsh(1) or hivexregedit(1).

ENCODING

"virt-win-reg" expects that regedit files have already been reencoded in the local encoding. Usually on Linux hosts, this means UTF-8 with Unix-style line endings. Since Windows regedit files are often in UTF-16LE with Windows-style line endings, you may need to reencode the whole file before or after processing.

To reencode a file from Windows format to Linux (before processing it with the "--merge" option), you would do something like this:

  iconv -f utf-16le -t utf-8 < win.reg | dos2unix > linux.reg
 
 

To go in the opposite direction, after exporting and before sending the file to a Windows user, do something like this:

  unix2dos linux.reg | iconv -f utf-8 -t utf-16le > win.reg
 
 

For more information about encoding, see Win::Hivex::Regedit(3).

If you are unsure about the current encoding, use the file(1) command. Recent versions of Windows regedit.exe produce a UTF-16LE file with Windows-style (CRLF) line endings, like this:

  $ file software.reg
  software.reg: Little-endian UTF-16 Unicode text, with very long lines,
  with CRLF line terminators
 
 

This file would need conversion before you could "--merge" it.

SHELL QUOTING

Be careful when passing parameters containing "\" (backslash) in the shell. Usually you will have to use 'single quotes' or double backslashes (but not both) to protect them from the shell.

Paths and value names are case-insensitive.

CurrentControlSet etc.

Registry keys like "CurrentControlSet" don't really exist in the Windows Registry at the level of the hive file, and therefore you cannot modify these.

"CurrentControlSet" is usually an alias for "ControlSet001". In some circumstances it might refer to another control set. The way to find out is to look at the "HKLM\SYSTEM\Select" key:

  # virt-win-reg WindowsGuest 'HKLM\SYSTEM\Select'
  [HKEY_LOCAL_MACHINE\SYSTEM\Select]
  "Current"=dword:00000001
  "Default"=dword:00000001
  "Failed"=dword:00000000
  "LastKnownGood"=dword:00000002
 
 

``Default'' is the one which Windows will choose when it boots.

Similarly, other "Current..." keys in the path may need to be replaced.

OPTIONS

--help
Display brief help.
--version
Display version number and exit.
--debug
Enable debugging messages.
--connect URI | -c URI
If using libvirt, connect to the given URI. If omitted, then we connect to the default libvirt hypervisor.

If you specify guest block devices directly, then libvirt is not used at all.

--merge
In merge mode, this merges a textual regedit file into the Windows Registry of the virtual machine. If this flag is not given then virt-win-reg displays or exports Registry entries instead.

Note that "--merge" is unsafe to use on live virtual machines, and will result in disk corruption. However exporting (without this flag) is always safe.

--encoding UTF-16LE|ASCII
When merging (only), you may need to specify the encoding for strings to be used in the hive file. This is explained in detail in ``ENCODING STRINGS'' in Win::Hivex::Regedit(3).

The default is to use UTF-16LE, which should work with recent versions of Windows.

SEE ALSO

hivex(3), hivexsh(1), hivexregedit(1), guestfs(3), guestfish(1), virt-cat(1), Sys::Guestfs(3), Sys::Guestfs::Lib(3), Win::Hivex(3), Win::Hivex::Regedit(3), Sys::Virt(3), <http://libguestfs.org/>.

BUGS

When reporting bugs, please enable debugging and capture the complete output:
  export LIBGUESTFS_DEBUG=1
  virt-win-reg --debug [... rest ...] > /tmp/virt-win-reg.log 2>&1
 
 

Attach /tmp/virt-win-reg.log to a new bug report at <https://bugzilla.redhat.com/>

AUTHOR

Richard W.M. Jones <http://people.redhat.com/~rjones/> Copyright (C) 2010 Red Hat Inc.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.