Page 1 of 1 1
Topic Options
#150738 - 2005-10-28 02:20 AM Opening old NTUSER.DAT to export old drives and printers into new profile
thrain78 Offline
Fresh Scripter

Registered: 2005-10-28
Posts: 7
Hello,
I've been working on a loop to migrate information from our old Windows 2000 Citrix Farm to our new Windows 2003 Citrix Farm. Due to application differences, we're not going to let the W2K profiles roam onto the 2003 servers.

Here is some code I wrote to migrate the \Desktop and \favorites shares from the old roaming profile location, and it works. It does not open the old NTUSER.DAT yet...


I need to modify this code to go into the \\corpfile\profiles\@userid directory and open the NTUSER.DAT that is here, then browse to \HKCU\Network\* and export it, then the HKCU\Printers\Connections\* keys, export them, then add this information into the current registry in HKCU.

What I don't know is how to
1. Load the old NTUSER.DAT as a hive
2. Navigate it once loaded, and then export these specificed Keys
3. Take whatever code does #1 & #2, then insert it into this loop.

ANY IDEAS ARE GREATLY APPRECIATED.

PLEASE AND THANKS.

-Ron

code:


$CitrixCheckVar = ReadValue ("HKEY_CURRENT_USER\Software\SchnitzerCitrix", "2K3ProfileMigrateDone");

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

use w: /d; disconnects the drive first, temp mapping to copy files and folders from old profile
use w: \\hydrogen3\personal_shares;

use x: /d; disconnects the drive first, temp mapping to copy files and folders from old profile
use x: "\\corpfile\profiles\@USERID";

use y: /d; disconnects the drive first, temp mapping to copy files and folders from old profile
use y: "\\hydrogen3\personal_shares\@USERID";

copy "X:\Desktop\*.*" "y:\OldCitrixDesktop\" /s ; copies the files from OLD Citrix TSE Desktop to new one
copy "P:\Internet\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s ; copies the files from OLD Citrix TSE Favorites to new one
copy "W:\*.lnk" "c:\documents and settings\" + @userid + "\Desktop\" ; copies a shortcut to P:\OldCitrixDesktop\ on new citrix desktop

use w: /d;
use x: /d;
use y: /d;

Writevalue("HKCU\Software\SchnitzerCitrix","2K3ProfileMigrateDone","1","REG_SZ")
ENDIF

Top
#150739 - 2005-10-28 02:56 PM Re: Opening old NTUSER.DAT to export old drives and printers into new profile
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
To load on old NTUser.dat, use the function LoadHive . You need to give the full name of the ntuser.dat file and the name of the registry key where to load the hive.

Code:
$filename = "c:\documents and settings\olduser\ntuser.dat"
$rootkey = "HKEY_USERS\olduser"
$ReturnCode = LoadHive( $rootkey, $filename)
If $ReturnCode = 0
? "Hive loaded...."

$CitrixCheckVar = ReadValue ($rootkey+"\Software\SchnitzerCitrix", "2K3ProfileMigrateDone")
IF $CitrixCheckVar = 1
? "This key exists, and therefore the ELSE Section has been done!";
else
...
...
$ReturnCode = Writevalue($rootkey+"\Software\SchnitzerCitrix","2K3ProfileMigrateDone","1","REG_SZ")

endif

$ReturnCode = UnLoadHive( $rootkey )
Endif

_________________________
Christophe

Top
#150740 - 2005-10-28 08:03 PM Re: Opening old NTUSER.DAT to export old drives and printers into new profile
thrain78 Offline
Fresh Scripter

Registered: 2005-10-28
Posts: 7
THanks so much for the hints. I've taken you're idea and went some with it, and tested. Now I am having an issue. The loadhive() command never gives a return code of 0, and keeps giving me a 1314...

What may be amiss?

Thanks again,
-Ron

IF @WKSTA = "NICKEL21" or @WKSTA = "NICKEL22" or @WKSTA = "NICKEL23" or @WKSTA = "NICKEL24" or @WKSTA = "NICKEL25"

; *BEGIN* Main Citrix Server Farm Loop Keep things between this line and the ending line

IF INGROUP ("eTIMEUsers")
use T: /d;
use T: "\\silver1\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\SchnitzerCitrix\ 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\SchnitzerCitrix", "2K3ProfileMigrateDone");

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

use w: /d; temp mapping to copy shortcut files from root of personal_share
use w: \\hydrogen3\personal_shares;

use x: /d; temp mapping to copy files and folders from old profile
use x: "\\corpfile\profiles\@USERID";

use y: /d; temp mapping to copy files and folders to new P Drive
use y: "\\hydrogen3\personal_shares\@USERID";

copy "X:\Desktop\*.*" "y:\OldCitrixDesktop\" /s ; copies the files from OLD Citrix TSE Desktop to new one
copy "X:\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s ; copies the files from OLD Citrix TSE Favorites to new one
copy "P:\Internet\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s ; copies the files from P: Favorites to new one
copy "W:\*.lnk" "c:\documents and settings\" + @userid + "\Desktop\" ; copies a shortcut to P:\OldCitrixDesktop\ on new citrix desktop

;This section below reads the old NTUSER.DAT from the Windows 2000 (NICKEL1X 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 = "x:\ntuser.dat";
$rootkey = "HKEY_USERS\Oldprofile";

$ReturnCodeLoadHive = LoadHive($rootkey,$filename)

? "The Return Code is = $ReturnCodeLoadHive

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

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

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

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

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

$ReturnCodeSaveDrives = SaveKey($rootkey + "\Network", "x:\" + @USERID + "drives.reg")

If $ReturnCodeSaveDrives = 0
? "Network Drives Key saved...."

$ReturnCodeLoadDrives = LoadKey("HKEY_CURRENT_USER\Network", "x:\" + @USERID + "drives.reg")

If $ReturnCodeLoadDrives = 0
? "Drives Key loaded...."
Endif
Endif
Endif

; Cleanup from what you've done above...

;unloads the loaded hive from above

$ReturnCodeLoadHive = UnLoadHive( $rootkey )

;disconnects the drives we mapped above to migrate the files

use w: /d;
use x: /d;
use y: /d;

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

Writevalue("HKCU\Software\SchnitzerCitrix","2K3ProfileMigrateDone","1","REG_SZ")
ENDIF

Top
#150741 - 2005-10-28 09:13 PM Re: Opening old NTUSER.DAT to export old drives and printers into new profile
thrain78 Offline
Fresh Scripter

Registered: 2005-10-28
Posts: 7
Alright, I found one problem w/ the error code 1314. It is "UserAccess Not Allowed"

The Help page for loadhive() mentions the need to have the user running it as having "Backup / Restore" rights.

I added "Domain Users" to the local "Backup Operators" group, and the 1314 went away.

Now, the section below that migrates the network drives is not working. The printers one is. On to troubleshoot this one.

Any ideas why the .reg file on the drives don't work and the printers do? the idea I'm running with is that the HKCU\Network\* keys define the persistent mapped drives that I want to move.

----------------------
IF @WKSTA = "NICKEL21" or @WKSTA = "NICKEL22" or @WKSTA = "NICKEL23" or @WKSTA = "NICKEL24" or @WKSTA = "NICKEL25"

; *BEGIN* Main Citrix Server Farm Loop Keep things between this line and the ending line

IF INGROUP ("eTIMEUsers")
use T: /d;
use T: "\\silver1\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\SchnitzerCitrix\ 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\SchnitzerCitrix", "2K3ProfileMigrateDone");

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

; temp mapping to copy shortcut files from root of personal_share
use w: \\hydrogen3\personal_shares;

; temp mapping to copy files and folders from old profile
use x: "\\corpfile\profiles\@USERID";

; temp mapping to copy files and folders to new P Drive
use y: "\\hydrogen3\personal_shares\@USERID";

copy "X:\Desktop\*.*" "y:\OldCitrixDesktop\" /s ; copies the files from OLD Citrix TSE Desktop to new one
copy "X:\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s ; copies the files from OLD Citrix TSE Favorites to new one
copy "P:\Internet\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s ; copies the files from P: Favorites to new one
copy "W:\*.lnk" "c:\documents and settings\" + @userid + "\Desktop\" ; copies a shortcut to P:\OldCitrixDesktop\ on new citrix desktop

;This section below reads the old NTUSER.DAT from the Windows 2000 (NICKEL1X 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 = "x:\ntuser.dat";
$rootkey = "HKEY_USERS\Oldprofile";

$ReturnCodeLoadHive = LoadHive($rootkey,$filename)

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

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

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

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

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

$ReturnCodeSaveDrives = SaveKey($rootkey + "\Network", "x:\" + @USERID + "drives.reg")

If $ReturnCodeSaveDrives = 0
? "Network Drives Key saved...."

$ReturnCodeLoadDrives = LoadKey("HKEY_CURRENT_USER\Network", "x:\" + @USERID + "drives.reg")

If $ReturnCodeLoadDrives = 0
? "Drives Key loaded...."
Endif
Endif
ELSE

? "The Return Code is = $ReturnCodeLoadHive";

Endif


; Cleanup from what you've done above...

;unloads the loaded hive from above

$ReturnCodeLoadHive = UnLoadHive( $rootkey );

;disconnects the drives we mapped above to migrate the files

use w: /d;
use x: /d;
use y: /d;

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

Writevalue("HKCU\Software\SchnitzerCitrix","2K3ProfileMigrateDone","1","REG_SZ")
ENDIF

Top
#150742 - 2005-10-28 09:21 PM Re: Opening old NTUSER.DAT to export old drives and printers into new profile
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Please use the UBB CODE TAGS and post your code between the CODE tags to preserve the formatting.
Top
#150743 - 2005-10-29 01:12 AM Re: Opening old NTUSER.DAT to export old drives and printers into new profile
thrain78 Offline
Fresh Scripter

Registered: 2005-10-28
Posts: 7
Oi, I give for the weekend. Hopefully some time away / help from yall will be the trick.

I get the printers to move successfully, but the LoadKey() where I call drives gives me "error code 2" which I cannot get any info on.

I tried doing this also:

Code:

; commented out as get "reg.exe failed to initialize" error when the following line is run. doh
; Shell "REG EXPORT HKU\Oldprofile\Network x:\mydrives.reg";
; If @error = 0
; ? "Network Drives Key Saved";
; Shell "REG IMPORT x:\mydrives.reg";
; If @error = 0
; ? "Network Drives Key Loaded...";
; endif
; endif




This gave me a "REG performed an illegal operation, exception 00000147 click ok to continue" when it went to run the reg export.
Any ideas?

Code:


IF @WKSTA = "NICKEL21" or @WKSTA = "NICKEL22" or @WKSTA = "NICKEL23" or @WKSTA = "NICKEL24" or @WKSTA = "NICKEL25"

; *BEGIN* Main Citrix Server Farm Loop Keep things between this line and the ending line

IF INGROUP ("eTIMEUsers")
use T: /d;
use T: "\\silver1\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\SchnitzerCitrix\ 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\SchnitzerCitrix", "2K3ProfileMigrateDone");

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

; temp mapping to copy shortcut files from root of personal_share
use w: \\hydrogen3\personal_shares;

; temp mapping to copy files and folders from old profile
use x: "\\corpfile\profiles\@USERID";

; temp mapping to copy files and folders to new P Drive
use y: "\\hydrogen3\personal_shares\@USERID";

copy "X:\Desktop\*.*" "y:\OldCitrixDesktop\" /s ; copies the files from OLD Citrix TSE Desktop to new one
copy "X:\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s ; copies the files from OLD Citrix TSE Favorites to new one
copy "P:\Internet\Favorites\*.*" "c:\documents and settings\" + @userid + "\Favorites\" /s ; copies the files from P: Favorites to new one
copy "W:\*.lnk" "c:\documents and settings\" + @userid + "\Desktop\" ; copies a shortcut to P:\OldCitrixDesktop\ on new citrix desktop

;This section below reads the old NTUSER.DAT from the Windows 2000 (NICKEL1X 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 = "x:\ntuser.dat";
$rootkey = "HKEY_USERS\Oldprofile";

$ReturnCodeLoadHive = LoadHive($rootkey,$filename)

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

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

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

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

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

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

Endif
Endif

$ReturnCodeSaveDrives = SaveKey($rootkey + "\Network", "x:\" + @USERID + "drives.reg");

If $ReturnCodeSaveDrives = 0
? "Drives Key saved...."

$ReturnCodeLoadDrives = LoadKey("HKEY_CURRENT_USER\Network", "x:\" + @USERID + "drives.reg")

If $ReturnCodeLoadDrives = 0
? "Network Drives Key loaded...."
Else
? "Network Drives did not load. Error Code : $ReturnCodeLoadDrives";
Endif
Endif
ELSE

? "The Return Code is = $ReturnCodeLoadHive";

Endif

; Cleanup from what you've done above...

;unloads the loaded hive from above

$ReturnCodeLoadHive = UnLoadHive( $rootkey );

;disconnects the drives we mapped above to migrate the files

use w: /d;
use x: /d;
use y: /d;

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

Writevalue("HKCU\Software\SchnitzerCitrix","2K3ProfileMigrateDone","1","REG_SZ")
ENDIF



Top
#150744 - 2005-10-29 02:45 AM Re: Opening old NTUSER.DAT to export old drives and printers into new profile
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Domain Users should NEVER be added to the Backup Operators group for security reasons.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#150745 - 2005-11-03 06:57 PM Re: Opening old NTUSER.DAT to export old drives and printers into new profile
thrain78 Offline
Fresh Scripter

Registered: 2005-10-28
Posts: 7
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!

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 836 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org