Link to home
Start Free TrialLog in
Avatar of DataDizzy
DataDizzyFlag for United States of America

asked on

SSIS Script Task to execute a .bat file or a scheduled task on a remote computer

I'm reasonably new to SSIS in SQL 2005 and have limited knowlege of scripting .bat files.  My problem is that we have a scheduled task on a remote server that I need to kick off from a SSIS Script Task and I need to know it completes successfully before I continue to the next steps.  The scheduled task runs successfully on the remote server and I can also successfully run the task from a .bat file on the remote server.  I need help with getting the SSIS package script task  to successfully execute either the remote task or the .bat file

Among other things, I have tried:

 Dim ShellObject = CreateObject("WScript.Shell")
        Dim strCmd As String
        Dim intReturn As Integer

        strCmd = "\\RemoteServerName\e$\Test\FileToRun.bat"

        intReturn = ShellObject.run(strCmd, , True)

        'MsgBox(intReturn)
        If intReturn = 0 Then

            Dts.TaskResult = Dts.Results.Success
        Else
            Dts.TaskResult = Dts.Results.Failure
        End If


Typically I find answers in previous postings from other people, but not this time, so I wonder if I'm even in the right ball park.   Any help, and/or sample code would be very much appreciated!

Thanks,
D.
ASKER CERTIFIED SOLUTION
Avatar of Reza Rad
Reza Rad
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DataDizzy

ASKER

Thank you!    This worked for me.

D.