From 8d8dc4c10700ee43bd026469665f5a16f6d2cbf5 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 10 Dec 2010 15:05:17 +0000 Subject: [PATCH] win-reg: Add Windows Tips to documentation. --- tools/virt-win-reg | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tools/virt-win-reg b/tools/virt-win-reg index c22b73c..2db2671 100755 --- a/tools/virt-win-reg +++ b/tools/virt-win-reg @@ -466,6 +466,96 @@ to find out is to look at the C key: Similarly, other C keys in the path may need to be replaced. +=head1 WINDOWS TIPS + +Note that some of these tips modify the guest disk image. The guest +I 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. For this example the script is called C +and it is uploaded into 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 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 with C. + +Now update the registry: + + virt-win-reg --merge WindowsGuest test.reg + +=head2 INSTALLING A SERVICE + +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 and we are using the +RHSrvAny wrapper: + + guestfish -i -d WindowsGuest < 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 + +Notes: + +=over 4 + +=item * + +For use of C 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. + +=back + +Update the registry: + + virt-win-reg --merge WindowsGuest service.reg + =head1 SHELL QUOTING Be careful when passing parameters containing C<\> (backslash) in the -- 1.8.3.1