Running a command (batch file) on a remote PC from SQL Server 2000

I am trying to run a batch file on a remote PC from SQL Server 2000 DTS.  
I created a Visual Basic ActiveX script interface in DTS.  I have attached the code below.
The DTS package completes successfully, but results from the Batch file are not seen.

I do not know how to debug vbscript in SQL server DTS or even if I have the DTS package setup properly.

Any help would be great.
'**********************************************************************
'  Visual Basic ActiveX Script
'************************************************************************

Function Main()
	Call RunBatchFile()
	Main = DTSTaskExecResult_Success
End Function

Sub RunBatchFile()
	strComputer = "simCompServer"
	Set objWMIService = GetObject _
	("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
	objWMIService.Create "D:\OperatorActions\3cfgserver.bat", Null, Null, intProcessID
End Sub

Open in new window

LovetoLaughAsked:
Who is Participating?
 
Anthony PerkinsCommented:
>>The DTS package completes successfully, but results from the Batch file are not seen.<<
That is because you are not checking the success or failure of the API call and instead are always setting the task to Success.

>>I do not know how to debug vbscript in SQL server DTS or even if I have the DTS package setup properly.<<
1. Right click on Data Transformation Services.
2. Select Properties
3. Enable "Turn on just-in-time debugging"
0
 
LovetoLaughAuthor Commented:
See the screen print of the DTS ActiveX Script Task (Sql-Server-2000-DTS-ActiveX-Scri.JPG)
Sql-Server-2000-DTS-ActiveX-Scri.JPG
0
 
LovetoLaughAuthor Commented:
How can I check the success or failure of the API call?
0
Network Scalability - Handle Complex Environments

Monitor your entire network from a single platform. Free 30 Day Trial Now!

 
LovetoLaughAuthor Commented:
The code works fine when I change
 strComputer = "simCompServer"
TO
 strComputer = "."

That is, I can run a batch file on the local machine with this code, but I am not able to run code on the remote machine.
0
 
Anthony PerkinsCommented:
>>How can I check the success or failure of the API call?<<
Send me the definition of this particular API and I may be able to figure it out.
0
 
LovetoLaughAuthor Commented:
Thank you for your help.  I'm trying a different approach.  So no need to pursue this further at the moment.
0
 
Anthony PerkinsCommented:
Never mind, I beleive I have figured it out:

Function Main()
        If RunBatchFile() = 0
              Main = DTSTaskExecResult_Success
        Else
              Main = DTSTaskExecResult_Failure
        End
End Function
 
Function RunBatchFile()
        strComputer = "simCompServer"
        Set objWMIService = GetObject _
        ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
        RunBatchFile = objWMIService.Create("D:\OperatorActions\3cfgserver.bat", Null, Null, intProcessID)
End Function
0
 
Anthony PerkinsCommented:
Here is the definition for the Create Method and all the potential errors:
Create Method of the Win32_Process Class
http://msdn.microsoft.com/en-us/library/aa389388(VS.85).aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.