Page 2 of 2 <12
Topic Options
#186108 - 2008-03-11 12:19 PM Re: Migrate Offline Files to a New Server [Re: NTDOC]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
.dabs eyes with tissue.

I'm over it now. ;-)


Edited by MarkMelanson (2008-03-11 12:20 PM)

Top
#186113 - 2008-03-11 02:07 PM Re: Migrate Offline Files to a New Server [Re: MarkMelanson]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
You're gonna fit right in around here! \:\)

GLenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#186122 - 2008-03-11 04:11 PM Re: Migrate Offline Files to a New Server [Re: NTDOC]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
 Originally Posted By: NTDOC
Hi Mark,

Just a few comments (I'll leave Glenn to help with the coding) \:D

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

 Originally Posted By: NTDOC

;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.

 Originally Posted By: NTDOC

: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

 Originally Posted By: NTDOC

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.

 Originally Posted By: NTDOC

If wanted the use of HKEY_CURRENT_USER can be shortened to: HKCU


Done

 Originally Posted By: NTDOC

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

 Originally Posted By: NTDOC

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

 Code:
$DrvSrvShr = Split(UCase($KeyName),"/",-1)
$DrvSrv = $DrvSrvShr[2]
$DrvShr = $DrvSrvShr[3]



Done

 Originally Posted By: NTDOC

You should also have a CASE1 in case none of your expected results are there in your Select statement.


Done

 Originally Posted By: NTDOC

Good luck and I'll let Glenn carry on from here.


New code is re-posted to the first message (v2.0)

Thanks

Top
#186137 - 2008-03-11 09:28 PM Re: Migrate Offline Files to a New Server [Re: MarkMelanson]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Wow - sounds great. I'll try to take a look at it later on today.

Not sure about the license issue. I'll take it up with the other moderators / admins and see what they think and get back to you on that.

Top
#186159 - 2008-03-12 12:02 PM Re: Migrate Offline Files to a New Server [Re: NTDOC]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
Thanks guys!

I'll be fine if you don't want to add it to the UDF library due to the licensing. I would suggest adding something to notice when you join the board/post code that by doing so your code is released as Public Domain. That way there is no question.


Edited by MarkMelanson (2008-03-12 12:26 PM)

Top
#186167 - 2008-03-12 06:04 PM Re: Migrate Offline Files to a New Server [Re: MarkMelanson]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
Updated to v2.1

Fixed error checking in log creation

Top
#186178 - 2008-03-12 07:08 PM Re: Migrate Offline Files to a New Server [Re: MarkMelanson]
MarkMelanson Offline
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)

 Code:
;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
#186204 - 2008-03-12 11:40 PM Re: Migrate Offline Files to a New Server [Re: MarkMelanson]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Oi Mark,

just a quick advice as I don't have time to read anything in deep these days: Just make sure you don't miss the next KiXgolf tournament and KiXtart will be sooner or later your 'forte'

As for the licensing thing: KiXtart is CareWare and all we (the posse) pulish here can be treated as FreeWare to be used with the CareWare, so I don't think a creative commons licensing would be suitable, sorry.

Oh, and welcome to the board!


Edited by Jochen (2008-03-12 11:40 PM)
_________________________



Top
#186235 - 2008-03-13 06:58 PM Re: Migrate Offline Files to a New Server [Re: Jochen]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
No problemo.
Top
#186236 - 2008-03-13 06:59 PM Re: Migrate Offline Files to a New Server [Re: MarkMelanson]
MarkMelanson Offline
Fresh Scripter

Registered: 2006-10-09
Posts: 24
Skipped to v2.4

Fixed condition where registry key was skipped

Top
#186267 - 2008-03-14 10:02 AM Re: Migrate Offline Files to a New Server [Re: MarkMelanson]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Just a few pointers:
 Code:
$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 but
 Code:
    CASE $Migstat <> 1
I think makes
 Code:
    CASE 1
obsolete.

Also you can shorten your code further by eliminating spaces
 Code:
$RetCode = WSHPipe("csccmd /MOVESHARE:\\" + $CSCSrv + "\" + $CSCShr + " \\" + $NewSrv + "\" + $CSCShr,1)

would look like this
 Code:
$RetCode = WSHPipe("csccmd /MOVESHARE:\\"+$CSCSrv+"\"+$CSCShr+" \\"+$NewSrv+"\"+$CSCShr,1)


Edited by apronk (2008-03-14 10:08 AM)
Edit Reason: added last suggestion

Top
#186286 - 2008-03-14 08:24 PM Re: Migrate Offline Files to a New Server [Re: Arend_]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Personally, I think that the elimination of spaces makes it more difficult to read, and prevents you from quickly recogniznig where each component begins/ends. Of course, if you're 22 and (still) have 20/20 vision... ;\)

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#186289 - 2008-03-14 08:56 PM Re: Migrate Offline Files to a New Server [Re: Arend_]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Yes the
 Code:
CASE $Migstat <> 1

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
#186431 - 2008-03-21 10:44 PM Re: Migrate Offline Files to a New Server [Re: NTDOC]
masken Offline
MM club member
*****

Registered: 2000-11-27
Posts: 1222
Loc: Gothenburg, Sweden
hmm... I remember that when I scripted this it was tricky. csccmd requires administrative privs and so on. If my memory serves me right, old share-references in hklm also needs to be deleted, and the csc re-initiated on the client side to really remove old refs. But this was all for dleting old offline servers, might be that this isn't valid for /MOVESHARE when the old server is still online... Well I'm too tired atm anyhow hehe...
_________________________
The tart is out there

Top
#191997 - 2009-01-30 08:44 PM Re: Migrate Offline Files to a New Server [Re: masken]
sns Offline
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 \:D


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 Offline
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
Page 2 of 2 <12


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

Who's Online
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.081 seconds in which 0.036 seconds were spent on a total of 13 queries. Zlib compression enabled.

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