8th November 1994

COPYREG v1.03: Copies registry subtree from one computer to another.

Comments, requests & bug-reps to : neil.ferguson@linacre.ox.ac.uk

Copyright & Legal Notice
========================
The program 'COPYREG' and this documentation file are copyright Neil M. Ferguson (Linacre College,
Oxford Univ., UK) 1994. The program may be freely distributed, subject to the following conditions:

1. The program shall not be renamed or modified in any way.
2. The program shall always be distributed with this documentation file.
3. The program may not be sold, or distributed via a medium (electronic or physical) for which
   any payment is required except in the case of users using commercial bulletin-board services
   as a gateway to software archives run on a non-commercial basis.
4. The Author (Neil Ferguson) of this program accepts no responsibility for any loss or damages
   caused directly or indirectly by the operation of this program. The Author makes no assurance
   that the program acts as described, and is takes no responsibility for any defects in the
   software. By executing the program, the user accepts these conditions.

Payment required for use.
=========================

1. Educational and governmental institutions, and individual users not using this program at their
   place of work, may use this software free of charge. A postcard to Neil Ferguson at Linacre
   College, St. Cross Road, Oxford OX1 3JA, U.K. would be appreciated though! (Shareware
   authors might consider sending me their latest software if they find this program useful!)

2. Commercial organisations may NOT use this software free of charge. Such organisations may
   purchase a single site license for US$50 (or 30 UK pounds stirling). Payment (in the form
   of a UK cheque or International Money order) should be sent to Neil Ferguson at Linacre
   College, St. Cross Road, Oxford OX1 3JA, U.K.. I haven't put any nags or expiry dates in
   the program, so be nice and cough up. Software companies may pay in kind.


Primary use of software: Registry replication (e.g. Common Program Groups, HKEY_CALSSES_ROOT).
=======================

Syntax:
=======

COPYREG [/s Src PC] [/d Dest PC] [/f Src key] /t Dest Key [/p] [/k] [/v] [/q] [/c Save_Config] [/r Run_Config]

  Src PC        UNC path of source computer (Defaults to local computer if option not specified)
		e.g. \\pc02

  Dest PC       UNC path of destination computer (Defaults to local computer if option not specified)
		e.g. \\pc01

  Src Key       Source registry path (relative to HKEY_LOCAL_MACHINE). Do not use quotes around path.
		e.g. SOFTWARE\Program Groups

  Dest Key      Destination registry path (relative to HKEY_LOCAL_MACHINE). Do not use quotes around path.
		This will default to the Source Key if /t not specified.
		e.g. SOFTWARE\Test\Program Groups Copy

  /p            Copy security information (excluding SACL). By default security info is not copied.

  /k            Delete destination key (and all subtrees) before copying starts.
                If no source key is given, this option has the effect of just deleting the dest. key.

  /v            Verbose option. Lists all keys/values being deleted or copied.

  /q            Quiet option - the disables all output (including errors). Overrides /v.
		If copyreg is run using the START or AT commands, this option hides the console window.
		N.B. The program cannot be interrupted with CTRL-C if /q is specified.

  Save_Config   If the /c option is given, the command configuration (i.e. all the above options)
		are saved under this name. (Configurations are actually stored in
		HKEY_CURRENT_USER\CopyReg\Save_Config) If no argument is given, the configuration
		name will default to the name given with the /r option.

		e.g. The following copies the Common Program Groups from \\pc01 to \\pc02, and saves
		the command configuration under the name CopyProgGroup for later use:

                   COPYREG /c CopyProgGroup /s \\pc01 /d \\pc02 /f SOFTWARE\Program Groups /k /p



  Run_Config    Name of previously stored command configuration to be run.]

		e.g. if the 'Save_Config' example above had been executed, the command could be
		re-run using

    			COPYREG /r CopyProgGroup

		N.B. The /r option can be specified in combination with any of the other flags.
		the /s /d /f /t command line options will over-ride the options specified in the
		stored configuration. The /p /k /q /v options will act as toggles when used in
		conjunction with the /r option; i.e. if /v was specified when a configuration
		was saved, that config. will run with the verbose option on unless /v is specified
		with /r.

		e.g. Continuing the above example, the following will copy program groups from
		\\server to \\pc02, but without first deleting the destination key, and using
		the quiet option:

			COPYREG /r CopyProgGroup /s \\server /k /q

		Adding a /c to the previous line would save the modified configuration under the
		same name.


Notes:
======

1. Unless the /k option is specified, subkeys and values under the destination key are changed
   only if they exist under the source key.

2. When parsing computer names and registry paths given on the command line, all spaces
   given within the relevant parameter will be used.

  e.g.    ... /f SOFTWARE\Program Groups  ... will copy from the key 'Program Groups' (1 space)
  whilst  ... /f SOFTWARE\Program  Groups ... will copy from the key 'Program  Groups' (2 spaces)

3. Registry paths and computer names with trailing or leading spaces may not be specified.

4. NOTE: ALL REGISTRY PATHS ARE SPECIFIED RELATIVE TO HKEY_LOCAL_MACHINE. This is because
   the registry APIs only permit access to HKEY_LOCAL_MACHINE and HKEY_USERS on remote
   computers, and for HKEY_USERS to be useful, one needs the SID of the currently logged on
   user. HKEY_CLASSES_ROOT can be accessed as SOFTWARE\Classes, for which it is an alias.

5. Copying large subtrees (e.g. SOFTWARE\Classes) is relatively slow (the registry APIs are not
   terribly fast!), so using START or AT with the /q option is advised.

6. COPYREG does not use the RegRestoreKey and RegSaveKey API functions, as these are rather
   temperamental when you want to copy over keys that are already in use by another process.

7. A user with any level of access permissions may use this program, but you can't copy or
   delete keys for which you don't have the required permissions.

8. This program has only been tested on Windows NT 3.5, build 807. It should work on NT3.1
   though. It MAY work on Windows 95.

9. I would be happy to compile this for the Alpha if DEC give me a compiler!

10.I may turn this program into a registry replication service. Contact me if you're interested.

11.A warning to those using this program for Program Group or OLE registrations (i.e. HKEY_CLASSES_ROOT) 
   replication: On NT3.5, not all changes made to Common program groups from within Progman are flushed to
   the registry until you log out, so logout & login again before using COPYREG to distribute modified Program
   Groups. Also, note that many WIN32 processes (e.g. Progman & the 32 bit OLE2 DLLs) seem to detect when
   their registry parameters are deleted (using /k) - presumably because their registry key handles are no
   longer valid (e.g. Common Program Groups will vanish on the destination computer). However, they
   do not always detect that the same keys have been recreated - so, in the case of Program Groups, the user
   on the destination machine needs to logout & login again before seeing the changed groups. IF YOU USE
   COPYREG TO REPLICATE HKEY_CLASSES_ROOT BETWEEN MACHINES, AND USE THE /K SWITCH, OLE2 WILL BECOME INOPERABLE
   ON THE TARGET MACHINES UNTIL THEY ARE REBOOTED. This is because the OLE2 dlls are 32 bit in Windows NT 3.5
   (Win16 processes use thunking stub dlls), and appear to be initialised when the WIn32 subsystem starts.
   They appear to detect when HKEY_CLASSES_ROOT is deleted, thereby disabling OLE2, and only reload the
   registration data when the computer is restarted. This problem does not appear to affect OLE1, however
   - for reasons I don't really understand. This also only applies if you use the /k option in COPYREG. Copying
   without using the /k option does NOT disable OLE2, though I'm not sure whether changes take immediate
   effect (I think they do).
 
12.BE VERY CAREFUL USING THIS PROGRAM!! It is quite easy to leave your machine in a completely
   unusable state:

   e.g. NEVER DO THIS (or anything like it): start copyreg /t SYSTEM /k /q

   By the time you found the PID of copyreg and 'kill'ed it, it probably would already be
   too late!

