Hi,

I was wondering if anybody could help me. I have written a script to move the user directories from one server to another. First of all in unshares the directory then copies it to the new location and then reshares it. I was wondering if there is a way i can check if that users directory is been mapped to before i unshare it so there is no chance of data loss. here is the code below:

code:
;Start Move
$UserDirList="G:\MoveDirs\Dirs.txt"
Open(1,$UserDirList,2)
$Dir=Readline(1)
While $Dir<>""
$SourceShare=$SourceServer + $Dir ; Share on source server to be removed
$DestShare=$DestServer + $Dir ; Share on destination server to be created
$SourceUserDir=$SourceDir + $Dir ; Path of the user dir on source server
$DestUserDir=$DestSharePath + $Dir ; Path of the user dir on destination server
$RmtUserDir=$MappedDrive + $Dir ; Location on the source server of the destination path
Shell "RmtShare $SourceShare /DELETE"
Shell "Robocopy $SourceUserDir $RmtUserDir /E /SEC /MOVE /XF paradox.cfg /+LOG:MoveUserDir.txt"
Shell "RmtShare $DestShare=$DestUserDir"
Shell "NTUser -s $PDC change $Dir -home_dir $DestServer$Dir -home_dir_drive $HomeDirDrive"
$Dir=Readline(1)
Loop
Close(1)
Return

I basically like something in the code that checks if the share is in use, if it is then it skips the whole lot.

any ideas?

thanks