1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
|
=encoding utf8
=head1 名前
virt-win-reg - Windows 仮想マシンからの Windows レジストリエントリーのエクスポートおよびマージ
=head1 書式
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 ... # 仮想マシン名の代わり
=head1 警告
You must I<not> use C<virt-win-reg> with the I<--merge> option on live
virtual machines. If you do this, you I<will> get irreversible disk
corruption in the VM. C<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 I<--merge> option, make sure
you have a reliable backup first.
=head1 説明
このプログラムは Windows 仮想マシンから Windows レジストリのエントリーをエクスポートおよびマージできます。
第一パラメーターは Windows 仮想マシンの libvirt 仮想マシン名または生のディスクイメージです。
If I<--merge> is I<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
I<--merge> を用いると、テキストの regedit ファイルを Windows レジストリーの中に結合できます:
$ virt-win-reg --merge Windows7 changes.reg
=head2 注記
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 L<libguestfs(3)> or L<guestfish(1)>
and access them locally, eg. using L<hivex(3)>, L<hivexsh(1)> or
L<hivexregedit(1)>.
=head1 オプション
=over 4
=item B<--help>
簡単なヘルプを表示します。
=item B<--version>
バージョン番号を表示して終了します。
=item B<--debug>
デバッグメッセージを有効にします。
=item B<-c URI>
=item B<--connect URI>
libvirt を使用していると、指定された I<URI> に接続します。 省略すると、デフォルトの libvirt ハイパーバイザーに接続します。
仮想マシンのブロックデバイスを直接指定すると、libvirt はまったく使用されません。
=item B<--format> raw
Specify the format of disk images given on the command line. If this is
omitted then the format is autodetected from the content of the disk image.
If disk images are requested from libvirt, then this program asks libvirt
for this information. In this case, the value of the format parameter is
ignored.
If working with untrusted raw-format guest disk images, you should ensure
the format is always specified.
=item B<--merge>
In merge mode, this merges a textual regedit file into the Windows Registry
of the virtual machine. If this flag is I<not> given then virt-win-reg
displays or exports Registry entries instead.
Note that I<--merge> is I<unsafe> to use on live virtual machines, and will
result in disk corruption. However exporting (without this flag) is always
safe.
=item B<--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
L<Win::Hivex::Regedit(3)/ENCODING STRINGS>.
The default is to use UTF-16LE, which should work with recent versions of
Windows.
=item B<--unsafe-printable-strings>
When exporting (only), assume strings are UTF-16LE and print them as strings
instead of hex sequences. Remove the final zero codepoint from strings if
present.
This is unsafe and does not preserve the fidelity of strings in the original
Registry for various reasons:
=over 4
=item *
Assumes the original encoding is UTF-16LE. ASCII strings and strings in
other encodings will be corrupted by this transformation.
=item *
Assumes that everything which has type 1 or 2 is really a string and that
everything else is not a string, but the type field in real Registries is
not reliable.
=item *
Loses information about whether a zero codepoint followed the string in the
Registry or not.
=back
This all happens because the Registry itself contains no information about
how strings are encoded (see L<Win::Hivex::Regedit(3)/ENCODING STRINGS>).
You should only use this option for quick hacking and debugging of the
Registry contents, and I<never> use it if the output is going to be passed
into another program or stored in another Registry.
=back
=head1 サポートされるシステム
The program currently supports Windows NT-derived guests starting with
Windows XP through to at least Windows 7.
以下のレジストリキーがサポートされます:
=over 4
=item C<HKEY_LOCAL_MACHINE\SAM>
=item C<HKEY_LOCAL_MACHINE\SECURITY>
=item C<HKEY_LOCAL_MACHINE\SOFTWARE>
=item C<HKEY_LOCAL_MACHINE\SYSTEM>
=item C<HKEY_USERS\.DEFAULT>
=item C<HKEY_USERS\I<SID>>
ここで I<SID> は Windows User SID です (例: C<S-1-5-18>)。
=item C<HKEY_USERS\I<username>>
ここで I<username> はローカルユーザー名です (これは libguestfs の拡張です)。
=back
You can use C<HKLM> as a shorthand for C<HKEY_LOCAL_MACHINE>, and C<HKU> for
C<HKEY_USERS>.
The literal keys C<HKEY_USERS\$SID> and C<HKEY_CURRENT_USER> are not
supported (there is no "current user").
=head1 エンコーディング
C<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 I<--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
エンコーディングの詳細は L<Win::Hivex::Regedit(3)> を参照してください。
If you are unsure about the current encoding, use the L<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 I<--merge> it.
=head1 CurrentControlSet etc.
Registry keys like C<CurrentControlSet> don't really exist in the Windows
Registry at the level of the hive file, and therefore you cannot modify
these.
C<CurrentControlSet> is usually an alias for C<ControlSet001>. In some
circumstances it might refer to another control set. The way to find out is
to look at the C<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
"Current" is the one which Windows will choose when it boots.
Similarly, other C<Current...> keys in the path may need to be replaced.
=head1 DELETING REGISTRY KEYS AND VALUES
レジストリキー全体を削除するには、この構文を使用します:
[-HKEY_LOCAL_MACHINE\Foo]
キーにある単一の値を削除するには、この構文を使用します:
[HKEY_LOCAL_MACHINE\Foo]
"Value"=-
=head1 Windows のヒント
Note that some of these tips modify the guest disk image. The guest I<must>
be shut off, else you will get disk corruption.
=head2 RUNNING A BATCH SCRIPT WHEN A USER LOGS IN
Prepare a DOS batch script, VBScript or executable. Upload this using
L<guestfish(1)>. For this example the script is called C<test.bat> and it
is uploaded into C<C:\>:
guestfish -i -d WindowsGuest upload test.bat /test.bat
Prepare a regedit file containing the registry change:
cat > test.reg <<'EOF'
[HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce]
"Test"="c:\\test.bat"
EOF
In this example we use the key C<RunOnce> which means that the script will
run precisely once when the first user logs in. If you want it to run every
time a user logs in, replace C<RunOnce> with C<Run>.
Now update the registry:
virt-win-reg --merge WindowsGuest test.reg
=head2 サービスのインストール方法
This section assumes you are familiar with Windows services, and you either
have a program which handles the Windows Service Control Protocol directly
or you want to run any program using a service wrapper like SrvAny or the
free RHSrvAny.
First upload the program and optionally the service wrapper. In this case
the test program is called C<test.exe> and we are using the RHSrvAny
wrapper:
guestfish -i -d WindowsGuest <<EOF
upload rhsrvany.exe /rhsrvany.exe
upload test.exe /test.exe
EOF
Prepare a regedit file containing the registry changes. In this example,
the first registry change is needed for the service itself or the service
wrapper (if used). The second registry change is only needed because I am
using the RHSrvAny service wrapper.
cat > service.reg <<'EOF'
[HKLM\SYSTEM\ControlSet001\services\RHSrvAny]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"="c:\\rhsrvany.exe"
"DisplayName"="RHSrvAny"
"ObjectName"="NetworkService"
[HKLM\SYSTEM\ControlSet001\services\RHSrvAny\Parameters]
"CommandLine"="c:\\test.exe"
"PWD"="c:\\Temp"
EOF
注:
=over 4
=item *
For use of C<ControlSet001> see the section above in this manual page. You
may need to adjust this according to the control set that is in use by the
guest.
=item *
C<"ObjectName"> controls the privileges that the service will have. An
alternative is C<"ObjectName"="LocalSystem"> which would be the most
privileged account.
=item *
For the meaning of the magic numbers, see this Microsoft KB article:
L<http://support.microsoft.com/kb/103000>.
=back
レジストリを更新します:
virt-win-reg --merge WindowsGuest service.reg
=head1 SHELL QUOTING
Be careful when passing parameters containing C<\> (backslash) in the
shell. Usually you will have to use 'single quotes' or double backslashes
(but not both) to protect them from the shell.
パスおよび値の名前は大文字小文字を区別します。
Libvirt guest names can contain arbitrary characters, some of which have
meaning to the shell such as C<#> and space. You may need to quote or
escape these characters on the command line. See the shell manual page
L<sh(1)> for details.
=head1 関連項目
L<hivex(3)>, L<hivexsh(1)>, L<hivexregedit(1)>, L<guestfs(3)>,
L<guestfish(1)>, L<virt-cat(1)>, L<Sys::Guestfs(3)>,
L<Sys::Guestfs::Lib(3)>, L<Win::Hivex(3)>, L<Win::Hivex::Regedit(3)>,
L<Sys::Virt(3)>, L<http://libguestfs.org/>.
=head1 バグ
バグを報告するとき、デバッグを有効にして、I<完全な> 出力を記録してください:
export LIBGUESTFS_DEBUG=1
virt-win-reg --debug [... rest ...] > /tmp/virt-win-reg.log 2>&1
L<https://bugzilla.redhat.com/> の新規バグ報告に /tmp/virt-win-reg.log を添付してください
=head1 著者
Richard W.M. Jones L<http://people.redhat.com/~rjones/>
=head1 COPYRIGHT
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., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|