LovetoLaugh
asked on
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.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How can I check the success or failure of the API call?
ASKER
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.
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.
>>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.
Send me the definition of this particular API and I may be able to figure it out.
ASKER
Thank you for your help. I'm trying a different approach. So no need to pursue this further at the moment.
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:\O peratorAct ions\3cfgs erver.bat" , Null, Null, intProcessID)
End Function
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:\O
End Function
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
Create Method of the Win32_Process Class
http://msdn.microsoft.com/en-us/library/aa389388(VS.85).aspx
ASKER
Sql-Server-2000-DTS-ActiveX-Scri.JPG