Finally - I was able to work out a solution. Thanks to all for your help.

Here is the running code I used, and links the the UDFs that helped me get to here.

I kept having problems w/ the output from savekey() looking not like a "normal reg file". It almost looked like a bunch of squares and smiley faces vs. what I was expecting:

Code:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Network]

data goes here...




Where the output from savekey() looked like this, and because of it I was not able to open, search for a text string, then replace it. Since I used LoadKey() and pointed the hive to HKEY_USER\@USERID the export had this instead of HKEY_CURRENT_USER\ this copy UDF worked like a champ in this case.

Code:

regf     

Øí x&Aâ- °Íã€u  



Here is the main KIX Loop.

It requires having a copy of "tree.kix" at the root, which can be found here:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=52468

Code:

;*******************************************************************************************************
; Citrix Server Farm Specific Mappings - Apply only to CITRIXSRV2X machines explicitly named in if statement
;*******************************************************************************************************

IF @WKSTA = "CITRIXSRV21" or @WKSTA = "CITRIXSRV22" or @WKSTA = "CITRIXSRV23" or @WKSTA = "CITRIXSRV24" or @WKSTA = "CITRIXSRV25"

; *BEGIN* Main Citrix Server Farm Loop Keep things between this line and the ending line
;
; This mapping for Employee Services and ADP users that run Etime
;

IF INGROUP ("eTIMEUsers")
use T: /d;
use T: "\\ACTGSVR\etime";
ENDIF

;
; Read HKEY_CURRENT_USER registry keys to see if something is there. We set these values at the end to mark it as "run once"
; We selected the subkey of HKEY_CURRENT_USER\Software\CompanyName\ as our root key to check for this sort of thing.
; The below section maps 3 Drives (root of PERSONAL_SHARES, old Citrix Profile, and new P: Drive, then copies the needed
; files out of the old profile. The new Citrix Desktop profiles we limit to 30MB, so we move this to P instead.
;

; This variable and check for a reg key is how we "do this once" and "only once"
; If it is there, then we have done the work before, and we want to skip.

$CitrixCheckVar = ReadValue ("HKEY_CURRENT_USER\Software\CompanyName", "2K3CitrixProfileMigrateDone");

; Have to declare the variable regpath outside of the loop or it does not run (it seems)
; We set the path to be dynamic so this script can execute by many users at once

$RegPath = "HKEY_USERS\" + @USERID;

IF $CitrixCheckVar = 1
? "This key exists, and therefore the ELSE Section has been done!";
ELSE

; copies the files from OLD Citrix TSE Desktop to new one
copy "\\OLDFILESRV\profiles\" + @userid + "\Desktop\*.*" "\\NEWFILESRV\personal_shares\" + @USERID + "\OldCitrixDesktop\" /s;
;
; copies the files from OLD Citrix TSE Favorites to new one
copy "\\OLDFILESRV\profiles\" + @userid + "\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s;
;
; copies the files from OLD Citrix QuickLaunch to new one
copy "\\OLDFILESRV\profiles\" + @userid + "\Application Data\Microsoft\Internet Explorer\Quick Launch\*.*" "\\NEWFILESRV\personal_shares\" + @USERID + "\OldCitrixDesktop\OldQuickLaunch\" /s;
;
; copies the files from P: Favorites to new one
copy "P:\Internet\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s;
;
; copies a shortcut to P:\OldCitrixDesktop\ on new citrix desktop
copy "\\NEWFILESRV\apps\shortcuts\old citrix desktop.lnk" "c:\documents and settings\" + @userid + "\Desktop\";
;
;This section below reads the old NTUSER.DAT from the Windows 2000 (CITRIXSRV1X Boxes) and exports
;mapped drives and printers from the HKEY_CURRENT_USER section of the registry, and then imports
;it to the new Windows 2003 User profile

$filename = "\\OLDFILESRV\profiles\" + @userid + "\ntuser.dat";
$rootkey = $RegPath;

$ReturnCodeLoadHive = LoadHive($rootkey,$filename);

If $ReturnCodeLoadHive = 0
? "Old Citrix Server Hive loaded....";

$ReturnCodeSavePrinter = SaveKey($rootkey + "\Printers\Connections", "\\OLDFILESRV\profiles\" + @USERID + "\printers.reg");

If $ReturnCodeSavePrinter = 0
? "Printers Key saved....";

$ReturnCodeLoadPrinter = LoadKey("HKEY_CURRENT_USER\Printers\Connections", "\\OLDFILESRV\profiles\" + @USERID + "\printers.reg")

If $ReturnCodeLoadPrinter = 0
? "Printers Key loaded....";

Else
? "Printer Key did not load. Error : $ReturnCodeLoadPrinter";

Endif
Endif

$ReturnCodeSaveIE = SaveKey($rootkey + "\Software\Microsoft\Internet Explorer\Main", "\\OLDFILESRV\profiles\" + @USERID + "\ie.reg");

If $ReturnCodeSaveIE = 0
? "IE settings Key saved...."

$ReturnCodeLoadIE = LoadKey("\Software\Microsoft\Internet Explorer\Main", "\\OLDFILESRV\profiles\" + @USERID + "\ie.reg")

If $ReturnCodeLoadIE = 0
? "IE settings Key loaded...."
Else
? "IE settings did not load. Error Code : $ReturnCodeLoadIE";
Endif
Endif

; Calls other kix file to copy the drive mappings section of the registry
;-----------------------------------------------
; Begin Registry SubRoutine
;-----------------------------------------------
;
; This routine was found in the UDF Library on Kixtart.org
; and can be found here:
; http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Number=52468
;
; Here is a subroutine that can copy move or rename
; a registry key. The whole thing is based on the
; "enumkeys.kix" (thanks Shawn !) script file that comes
; with the kixtart distribution.
;
; In order this subroutine to work you have first to
; define The $source_key, $destination_key, and $action
; $action can be : "move", "rename", or "copy"
;
; This script comes in two parts. The main script
; below is actually your script and can have
; any name. Be carefull to place the "tree.kix" at the
; same directory as this file

$RegKey = "HKEY_USERS\" + @USERID;
$source_key = "$RegKey\Network"
$destination_key = "HKEY_CURRENT_USER\Network"
$action = "copy"
gosub manage_key
;----------------------------------------------------------
; Subroutines
;----------------------------------------------------------
goto end
:manage_key
gosub security_check if $secheck=1 return endif
gosub correct_key_names $zz=len($source_key)
call tree.kix
if $action <> "copy"
$nul=deltree("$source_key")
endif
return
;-----------------------
:correct_key_names
if substr($source_key,len($source_key),1)="\"
$source_key=substr($source_key,1,len($source_key)-1)
endif
if substr($destination_key,len($destination_key),1)="\"
$destination_key=substr($destination_key,1,len($destination_key)-1)
endif
return
;-----------------------
:security_check
$secheck=0
select
case ( ( $action<>"move" ) and ( $action<>"copy" ) and ( $action<>"rename" ) )
$secheck=1 'The variable $$action is not defined right. Please use' ?
'for this variable one of the following values :' ?
'"move" , "rename" , or "copy"' ?
case exist( @scriptdir + "\" + "tree.kix" )<>1
$secheck=1 'The library file "tree.kix" could not be found' ?
'at current directory' ?
case $source_key=""
$secheck=1 'You have not define the $$source_key' ?
case $destination_key=""
$secheck=1 'You have not define the $$destination_key' ?
case existkey("$source_key")<>0
$secheck=1 'The source key does not exist' ?
case existkey("$destination_key")=0
$secheck=1 'The destiantion key already exist. The destination' ?
'key must be absent in order this script to work.' ?
return
case addkey("$destination_key")<>0
$secheck=1 'Can not create the destination key. Probably you' ?
'do not have the required permissions' ?
endselect
$nul=delkey("$destination_key")
:quit_with_error2
return
;-----------------------
:end

;-----------------------------------------------
; End Registry Subroutine
;-----------------------------------------------

ELSE

? "The Return Code is = $ReturnCodeLoadHive";

Endif

;unloads the loaded hive from above

$ReturnCodeLoadHive = UnLoadHive( $rootkey );

;Write the registry key that shows we've done this before, so it is not done again

Writevalue("HKCU\Software\CompanyName","2K3CitrixProfileMigrateDone","1","REG_SZ")
ENDIF

; *END* Main Citrix Server Farm Loop Keep things between this line and the beginning line

ENDIF



I know the code is not elegant, but it works well and fast. Any comments on making it better or anything else? Thanks Peter for your assist!