This method cancels a replication.
Syntax
ReplicationInstance.Cancel
Remarks
You must have Site Server Publishing administrator privileges on the server to call this method.
Example
The following example cancels and displays the names of the replications where the status is other than NOERROR.
Option Explicit
On Error Resume Next
const OPEN_EXISTING_PROJECT = 2
const REPL_STATE_RUNNING = 2
const CRS_ERROR_NO_MORE_ITEMS = 0&80003B17
dim ReplServer
set ReplServer = CreateObject("CrsApi.ReplicationServer")
ReplServer.Initialize("")
dim ReplProject
set ReplProject = ReplServer.OpenProject("Project1", OPEN_EXISTING_PROJECT)
dim Iterator
Iterator = 0
dim Inst
Wscript.Echo "The following replications were cancelled:"
do while True
'Clear any error text
Err.Clear
'Get a replication instance
set ReplInst = ReplProject.EnumReplications(REPL_STATE_RUNNING, Iterator)
'Quit if empty object returned (no more instances)
if IsEmpty(ReplInst) then exit do
'Quit if "No more items" error
dim ReplError
ReplError = Err.Number
if ReplError = CRS_ERROR_NO_MORE_ITEMS then exit do
dim ReplStatus
ReplStatus = ReplInst.Status
if Status <> NOERROR
'Cancel it!
ReplInst.Cancel
Wscript.Echo ReplInst.Name
end if
Loop
'Release objects
set ReplInst = Nothing
set ReplProject = Nothing
set ReplServer = Nothing
See Also