#186122 - 2008-03-11 04:11 PM
Re: Migrate Offline Files to a New Server
[Re: NTDOC]
|
MarkMelanson
Fresh Scripter
Registered: 2006-10-09
Posts: 24
|
Hi Mark, Just a few comments (I'll leave Glenn to help with the coding)  KiXtart v4.x Unless you've tested it with KiXtart 4.0, 4.02, 4.22, etc... then I'd enter the version you did test under dependencies.
Done
;License: Creative Commons Attribution 3.0 United States ; http://creativecommons.org/licenses/by/3.0/us/Though this is not a bad deal I don't think we can accept it as a posted UDF with this license We've never actually used any type of license (probably should have) but have basically used the principal that ALL publicly posted code on the site is free to use in any shape form or manner one wishes to.
This is a little more complex. As I'm sure you are aware this license leaves it open to use by anyone only attribution is required. Living in the Land of the Free and the Home of the Lawyers my concern is that some scumbag might take some of the code and patent/register/trademark (WHATEVER, I don't care for lawyers) it making it unusable without some onerous license.
I do not recall, although it was quite awhile ago, seeing anything about licensing of code posted when I joined. If it is there then it is all good as long as this board stays up as a refencence for prior art.
Yes, I am paranoid. I have enough experience with lawyers to expect the worst.
:OLoop The use of GOTO and LABELS is considered [old school, out of date] coding practice. Though quite valid to use, we would rather it be coded to prevent it's use especially for a posted UDF.
Done
Though not required you may want to either code for it or make a point that the SERVER names should not contain a UNC path
This should never happen. The key is the format // + ServerName + / + ShareName. If it does happen the CSCCMD.EXE will throw an error that I capture.
If wanted the use of HKEY_CURRENT_USER can be shortened to: HKCU
Done
As mentioned about making the UDF silent, I would remove some of the minor items still left in that were not silent such as CLS ? "Pointing Offline Files to New Server..." etc...
Done
I'm not actually sure what's it's official name is but you may want to preload your arrays in case of an invalid read it would abend KiX $DrvSrvShr = Split(UCase($KeyName),"/",-1)
$DrvSrv = $DrvSrvShr[2]
$DrvShr = $DrvSrvShr[3]
Done
You should also have a CASE1 in case none of your expected results are there in your Select statement.
Done
Good luck and I'll let Glenn carry on from here.
New code is re-posted to the first message (v2.0)
Thanks
|
|
Top
|
|
|
|
#186178 - 2008-03-12 07:08 PM
Re: Migrate Offline Files to a New Server
[Re: MarkMelanson]
|
MarkMelanson
Fresh Scripter
Registered: 2006-10-09
Posts: 24
|
Coming in v2.3 (after testing)
Changed some variable names Restructured code to move If statement into SELECT CASE Restructured return codes (not backward compatible)
;Returns 0 - Offline Files are DISABLED
; 1 - NOTHING TO DO (Targeted Server not found to be configured on the client)
; 2 - ALL Targeted Offline Files were repointed successfully
; 3 - SOME Targeted Offline Files were repointed successfully
; Check the log for what failed at: $Temp\@UserID_OfflineFail.log
; 4 - NONE of the Targeted Offline Files were repointed successfully
; Check the log for what failed at: $Temp\@UserID_OfflineFail.log
; 5 - SOME Targeted Offline Files were repointed successfully
; Log Creation FAILED
; 6 - NONE of the Targeted Offline Files were repointed successfully
; Log Creation FAILED
; 7 - UNKNOWN ERROR
;
|
|
Top
|
|
|
|
#186267 - 2008-03-14 10:02 AM
Re: Migrate Offline Files to a New Server
[Re: MarkMelanson]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Just a few pointers:
$KeyName = ENUMKEY("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\NetCache\Shares\", $Index) You can use "HKCU" instead of the full "HKEY_CURRENT_USER" to shorten your code, also the trailing "\" isn't neccesary.
Not entirely sure about this one butI think makesobsolete.
Also you can shorten your code further by eliminating spaces$RetCode = WSHPipe("csccmd /MOVESHARE:\\" + $CSCSrv + "\" + $CSCShr + " \\" + $NewSrv + "\" + $CSCShr,1) would look like this$RetCode = WSHPipe("csccmd /MOVESHARE:\\"+$CSCSrv+"\"+$CSCShr+" \\"+$NewSrv+"\"+$CSCShr,1)
Edited by apronk (2008-03-14 10:08 AM) Edit Reason: added last suggestion
|
|
Top
|
|
|
|
#186289 - 2008-03-14 08:56 PM
Re: Migrate Offline Files to a New Server
[Re: Arend_]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Yes the
would negate the CASE 1
Missed that
I'm also with Glenn on not removing all the spaces, and it should also have liberal comments for future reference unless it's personal code on your own machine, but most often its for a Company you work for and sooner or later someone else will need to work on your code. Without comments it can make it difficult for a new person to determine what all it does.
|
|
Top
|
|
|
|
#191997 - 2009-01-30 08:44 PM
Re: Migrate Offline Files to a New Server
[Re: masken]
|
sns
Just in Town
Registered: 2009-01-30
Posts: 2
Loc: Canada
|
I am new to the forum (1st post) and a newbie to kixtart! This udf would fix a major issue I have at one of my cleints sites. The question I have is: how do I apply this udf in a script? I know that the "syntax" states to use MigOfflineFiles("ServerOld", "ServerNew") but when I replace the server old and server new with the names of the servers, I get this error:
ERROR : expected ')'! Script: U:\offlinefiles.KIX Line : 65
This is basically how it looks in the my offlinefiles.kix file:
MigOfflineFiles("myoldservername", "mynewservername")
----UDF below---- line 64 ; Is Offline Files enabled? line 65 $RetCode = WSHPipe("csccmd /IsEnabled",1) line 66 If UCase($RetCode[0]) = "DISABLED"
I went through and read the forum sticky on using udfs in script but I think maybe Im just to new to get this one going w/o any help. Any one have any idea what I am doing wrong?
*edit* I needed to add the udf "wshpipe" into the script. Now it's returning values.
After implementing this udf into my kix logon script I found that the warning in the notification area was still complaining about being offline on the old server. it was also still throwing errors when trying to synchronize. After doing some digging I found that if this is run once and the computer restarted this will clear those warnings.
reg add "hklm\SOFTWARE\Microsoft\Windows\CurrentVersion\netcache" /v FormatDatabase /t reg_dword /d 00000001
I put this into my current login script after the original script is called "\\myserver\netlogon\kix32 \\myserver\netlogon\kixtart.kix" in my batch file.
Hope this helps
Edited by sns (2009-02-06 04:00 PM)
|
|
Top
|
|
|
|
#196762 - 2009-11-19 06:36 AM
Re: Migrate Offline Files to a New Server
[Re: sns]
|
kmkix
Just in Town
Registered: 2009-11-19
Posts: 1
Loc: New York
|
Hey guys -- need a little help. The script didn't seem to run properly but I was able to run CSCCMD manually to update the offline cache file locations/etc using the MOVESHARE command.
SERVER1 (old) SERVER2 (new -- copy of data on SERVER1) PC (offline cache of data from SERVER1 -- user has not resynced with SERVER1 since X days ago -- so PC has newer data than some of what may exist on SERVER1 and SERVER2)
During my tests -- after the MOVESHARES change the problem comes up that on a re-sync with SERVER2 where the OFFLINE FILES CACHE now points -- SERVER2 does not update with any changes from the PC's cache. And, subsequently -- if there is a new file on the PC that's not on SERVER2 -- it gets deleted from the offline cache as well during the sync.
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 2682 anonymous users online.
|
|
|