Microsoft KB Archive/315229

= Text version of Dltpurge.vbs for Microsoft Knowledge Base article Q312403 =

Article ID: 315229

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft Windows 2000 Server
 * Microsoft Windows 2000 Advanced Server
 * Microsoft Windows 2000 Professional Edition
 * Microsoft Windows 2000 Datacenter Server
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise x64 Edition
 * Microsoft Windows Server 2003, 64-Bit Datacenter Edition
 * Microsoft Windows XP Professional
 * Microsoft Windows Small Business Server 2003 Premium Edition
 * Microsoft Windows Small Business Server 2003 Standard Edition

-



This article was previously published under Q315229



SUMMARY
You can use the Distributed Link Tracking service in Windows to track the creation and movement of linked files across NTFS-formatted volumes and servers. This article contains a text version of the Dltpurge.vbs script that is described in the following Microsoft Knowledge Base article:

312403 Distributed link tracking on Windows 2000-based domain controllers



MORE INFORMATION
To use this script:  Copy all of the text between the  tag and the  tag in this article, and then paste the text to a ASCII text editor file (for example, a Microsoft Notepad file). Save the file as &quot;Dltpurge.vbs&quot;. Complete the procedure that is described in the following Microsoft Knowledge Base article:

312403 Distributed link tracking on Windows 2000-based domain controllers



 '============================================================================== '============================================================================== ' ' Copyright (C) 2001 by Microsoft Corporation. All rights reserved. ' ' This script deletes all Active Directory objects used by the ' Distributed Link Tracking Server service. ' ' It is assumed that the DLT Server service has been disabled, ' and you wish to recover the DIT space these objects occupy. ' ' Usage:  cscript DltPurge.vbs ' Options: -s ServerName '         -d distinguishedname dc=mydomain,dc=mycompany,dc=com '         -b BatchSize  BatchDelayMinutes '         -t (optional test mode) ' ' The objects are deleted in batches - BatchSize objects are deleted, ' then there is a BatchDelayMinutes delay before the next batch. ' '============================================================================== '==============================================================================

Option Explicit

' ' Globals, also local to main. ' Dim oProvider Dim oTarget Dim sServer Dim sDomain Dim bTest

Dim BatchSize Dim BatchDelayMinutes

' ' Set defaults '

BatchSize = 1000 BatchDelayMinutes = 15 bTest = False

'============================================================================== ' '  ProcessArgs ' '  Parse the command-line arguments. Results are set in global variables '  (oProvider, oTarget, sServer, sDomain, BatchSize, and BatchDelayMinutes). ' '==============================================================================

public function ProcessArgs

Dim iCount Dim oArgs

on error resume next

'   ' Get the command-line arguments '   Set oArgs = WScript.Arguments

if oArgs.Count > 0 then

'       ' We have command-line arguments. Loop through them. '

iCount = 0 ProcessArgs = 0

do while iCount < oArgs.Count

select case oArgs.Item(iCount)

'               ' Server name argument '               case &quot;-s&quot;

if( iCount + 1 >= oArgs.Count ) then Syntax ProcessArgs = -1 exit do                   end if

sServer = oArgs.Item(iCount+1) if Len(sServer) > 0 then sServer = sServer & &quot;/&quot; iCount = iCount + 2

'               ' Enable testing option '               case &quot;-t&quot;

iCount = iCount + 1 bTest = True

'               ' Domain name option '               case &quot;-d&quot;

if( iCount + 1 >= oArgs.Count ) then Syntax ProcessArgs = -1 Exit Do                   end if

sDomain = oArgs.Item(iCount+1) iCount = iCount + 2

'               ' Batching option (batch size, batch delay) '

case &quot;-b&quot;

if( iCount + 2 >= oArgs.Count ) then Syntax ProcessArgs = -1 exit do                   end if

Err.Clear BatchSize = CInt( oArgs.Item(iCount+1) ) BatchDelayMinutes = CInt( oArgs.Item(iCount+2) ) if( Err.Number <> 0 ) then wscript.echo &quot;Invalid value for -b argument&quot; & vbCrLf Syntax ProcessArgs = -1 exit do                   end if                    iCount = iCount + 3

'               ' Help option '               case &quot;-?&quot; Syntax ProcessArgs = -1 exit do

'               ' Invalid argument '               case else ' Display the syntax and return an error

wscript.echo &quot;Unknown argument: &quot; & oArgs.Item(iCount) & vbCrLf Syntax ProcessArgs = -1 Exit Do           end select loop

else '       ' There were no command-line arguments, display the syntax ' and return an error. '

Syntax ProcessArgs = -1

end if

Set oArgs = Nothing

end function ' ProcessArgs

'============================================================================== ' '  Syntax ' '  Show the command-line syntax ' '==============================================================================

public function Syntax

wscript.echo   vbCrLf & _ &quot;Purpose:  Delete Active Directory objects from Distributed Link Tracking&quot; & vbCrLf & _ &quot;          Server service (Assumes that DLT Server has been disabled&quot; & vbCrLf & _                    &quot;           on all DCs)&quot; & vbCrLf & _ vbCrLf & _ &quot;Usage:    &quot; & wscript.scriptname & &quot; &quot; & vbCrLf & _ vbCrLf & _ &quot;Arguments: -s Server&quot; & vbCrLf & _ &quot;          -d FullyQualifiedDomain&quot; & vbCrLf & _ &quot;          -b BatchSize BatchDelayMinutes (default to 1000 and 15)&quot; & vbCrLf & _ &quot;          -t (optional test mode, nothing is deleted)&quot; & vbCrLf & _ vbCrLf & _ &quot;Note:     Objects are deleted in batches, with a delay between each&quot; & vbCrLf & _ &quot;          batch. The size of the batch defaults to 1000 objects, and&quot; & vbCrLf & _ &quot;          the length of the delay defaults to 15 minutes. But these&quot; & vbCrLf & _ &quot;          values can be overridden using the -b option.&quot; & vbCrLf & _ vbCrLf & _ &quot;Example:  &quot; & wscript.scriptname & &quot;  -s  myserver  -d distinguishedname dc=mydomain,dc=mycompany,dc=com &quot;

end function   ' Syntax

'============================================================================== ' '  PurgeContainer ' '  Delete all objects of the specified class in the specified container. '  This subroutine is called once for the volume table and once for '  the object move table. ' '==============================================================================

sub PurgeContainer(ByRef oParent, ByVal strClass)

dim oChild dim iBatch dim iTotal

On Error Resume Next

iTotal = 0 iBatch = 0

' Loop through the children of this container

For Each oChild in oParent

'        ' Is this a DLT object? '

if oChild.Class = strClass Then

'           ' Yes, this is a DLT object, it may be deleted '           iTotal = iTotal + 1 iBatch = iBatch + 1

'           ' Delete the object '           if bTest then wscript.echo &quot;Object that would be deleted: &quot; & oChild.adspath else oParent.Delete oChild.Class, oChild.Name end if

'           ' If this is the end of a batch, delay to let replication ' catch up. '           if iBatch = BatchSize then iBatch = 0 wscript.stdout.writeline &quot;&quot; ' ignored by wscript wscript.echo &quot;Deleted &quot; & BatchSize & &quot; objects&quot; wscript.echo &quot;Pausing to allow processing (will restart at &quot; & DateAdd(&quot;n&quot;, BatchDelayMinutes, Time) & &quot;)&quot; wscript.sleep BatchDelayMinutes * 60 * 1000 wscript.echo &quot;Continuing ...&quot; end if       else ' oChild.Class didn't match strClass wscript.echo &quot;Ignoring unexpected class: &quot; & oChild.Class end if

oChild = NULL

Next

wscript.echo &quot;Deleted a total of &quot; & iTotal & &quot; objects&quot;

end sub ' PurgeContainer

'============================================================================== ' ' Main ' '==============================================================================

if (ProcessArgs=-1) then wscript.quit

on error resume next

' ' Explain what's about to happen '

wscript.stdout.writeline &quot;&quot; ' ignored by wscript wscript.echo &quot;This script will purge all objects from the Active Directory&quot; & vbCrLf & _ &quot;used by the Distributed Link Tracking Server service (trksvr).&quot; & vbCrLf & _ &quot;It is assumed that this service has already been disabled on&quot; & vbCrLf & _ &quot;all DCs in the domain.&quot;

' ' When running in cscript, pause to give an opportunity to break out ' (These 3 lines are for cscript and ignored by wscript.) '

wscript.stdout.writeline &quot;&quot; wscript.stdout.writeline &quot;Press Enter to continue ...&quot; wscript.stdin.readline

' ' Get an ADSI object '

Set oProvider = GetObject(&quot;LDAP:&quot;)

' ' Purge the System/FileLinks/ObjectMoveTable '

wscript.stdout.writeline &quot;&quot; ' ignored by wscript wscript.echo &quot;Purging ObjectMoveTable&quot;

Set oTarget = oProvider.OpenDSObject( &quot;LDAP://&quot; & sServer & &quot;cn=ObjectMoveTable,CN=FileLinks,CN=System,&quot; & sDomain ,_                                      vbNullString, vbNullString, _                                      1) ' ADS_SECURE_AUTHENTICATION

call PurgeContainer( oTarget, &quot;linkTrackOMTEntry&quot; ) oTarget = NULL

' ' Purge the System/FileLinks/VolumeTable '

wscript.stdout.writeline &quot;&quot; ' ignored by wscript wscript.echo &quot;Purging VolumeTable&quot;

Set oTarget = oProvider.OpenDSObject(&quot;LDAP://&quot; & sServer & &quot;cn=VolumeTable,CN=FileLinks,CN=System,&quot; & sDomain  ,_                                     vbNullString, vbNullString, _                                     1) ' ADS_SECURE_AUTHENTICATION call PurgeContainer( oTarget, &quot;linkTrackVolEntry&quot; ) oTarget = NULL

oProvider = NULL 

Keywords: kbenv kbinfo KB315229

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.