DTS and Active X Task

  • I have created a DTS Package using an Active X Task. The process is as follows:

    1) Delete a folder on a computer on my network (\\c-grip-anly08l\TestFolder\")

    2) Copy a folder from another computer on the network to the same computer that I deleted the folder from. ("\\c-grip-anly-15\TestFolder\")

    Basically replacing a folder and its contents from a source computer to a destination computer. The source computer will always retain the original folder and simply copy the contents to another computer on the network. Here is the Active X Task script that I have so far. I have tested but I keep getting an error.

    '**********************************************************************

    ' Visual Basic ActiveX Script

    '************************************************************************

    Function Main()

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set strDTSSourceDir = objFSO.Getfolder("\\c-grip-anly-15\TestFolder\")

    Set strDTSDestinationDir = objFSO.Getfolder("\\c-grip-anly-08l\TestFolder\")

    ' First delete the original folder containing MedNet

    ' application on the remote machines

    IF (objFSO.FolderExists(strDTSDestinationDir)) THEN

    ' First Delete the Folder if it exists on remote laptops

    objFSO.Delete strDTSDestinationDir

    ' Then copy over all the source files from production

    objFSO.Copy strDTSSourceDir, strDTSDestinationDir & "\", False

    Success = "Your Folders have been moved to: " & strDTSDestinationDir

    Response.Write Success

    ' OR

    MsgBox (Success)

    ELSE

    Failure = "Your Folders were not moved to: " & strDTSDestinationDir

    Response.Write Failure

    ' OR

    MsgBox (Failure)

    END IF

    Set folderObject = Nothing

    Set fso = Nothing

    Main = DTSTaskExecResult_Success

    End Function

  • Try commenting out the Response.Write functions. I do not think those are supported in ActiveX scripting. They are ASP functions.

    Steve Hughes

    Magenic Technologies

  • Not only are the Response.Writes an issue, but you really don't want to return DTSTaskExecResult_Success if the folder wasn't copied, right?

    Try this. It will return a failure for the DTS Task if the files aren't copied. This allows you to use workflow. If you want notification use On Success to run a SQLMail task to send you a success notification, ditto using On Failure:

    IF (objFSO.FolderExists(strDTSDestinationDir)) THEN

    ' First Delete the Folder if it exists on remote laptops

    objFSO.Delete strDTSDestinationDir

    ' Then copy over all the source files from production

    objFSO.Copy strDTSSourceDir, strDTSDestinationDir & "\", False

    Main = DTSTaskExecResult_Success

    ELSE

    Main = DTSTaskExecResult_Failure

    END IF

    Set folderObject = Nothing

    Set fso = Nothing

    End Function

     

  • I would add to that to check for errors using ON ERROR RESUME NEXT and checking the ERR object to make sure you never loose the control!


    * Noel

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply