Function RunDTS(packageName)
 Dim objPkg, strError, iCount
 ‘Execute the package
 WriteLog “Executing DTS ” & packageName
 Set objPkg = CreateObject(“DTS.Package”)
 objPkg.LoadFromSQLServer MIIS_MachineName,,,DTSSQLStgFlag_UseTrustedConnection,,,,packageName
 objPkg.Execute
 ‘Check For Errors
 For iCount = 1 To objPkg.Steps.Count
   If objPkg.Steps(iCount).ExecutionResult = DTSStepExecResult_Failure Then
     strError = strError + objPkg.Steps(iCount).Name + ” failed. ” + chr(13)
   End If
 Next
Â
 If strError = “” Then
   WriteLog “DTS package ” & packageName & ” completed successfully”
   RunDTS = 0
 Else
   WriteLog “DTS package ” & packageName & ” failed with error ” & strError
   RunDTS = -1
 End If
 Set objPkg = Nothing
End Function