Bandwidth Monitor
SQLDTS.comSQLIS.comSQLIS Wiki
How to manipulate the Execute Process task.
By Allan Mitchell
Version 7.0/2000
Level Intermediate

Here is some code showing how we can dynamically manipulate the Execute Process task. Say we have an executable "c:\PassFile.exe" and it accepts one argument /F which is for a file. We want to be able to pass in whatever file we choose and we also want to be able to set some of the properties of the task like how long it will wait before timing out.

Here are the Global Variables we shall be using in the package

Global Variable Name Type Example Value
gv_strTextFilename String c:\MyFile.txt
gv_i_SuccessCode Integer 1
gv_i_Timeout Integer 30
gv_b_TermAfterTimeout Boolean True

        
Function Main()

	dim pkg
	dim cus
	dim strCmdLine
	
	

	set pkg = DTSGlobalVariables.Parent

	set cus = pkg.Tasks("DTSTask_DTSCreateProcessTask_1").Customtask
	
	'Build the commandline string
	
	strCmdLine = "c:\PassFile.exe /F" & _
		DTSGlobalVariables("gv_strTextFilename").Value


	'assign it to the ProcessCommandline property

	cus.ProcessCommandLine = strCmdLine

	'Assign our success return code

	cus.SuccessReturnCode = DTSGlobalVariables("gv_i_SuccessCode").Value

	'How long do we want to wait for the process to finish ?

	cus.Timeout = DTSGlobalVariables("gv_i_Timeout").Value

	'If we reach our timeout value should we terminate the process ?

	cus.TerminateProcessAfterTimeout = _
		DTSGlobalVariables("gv_b_TermAfterTimeout").Value
	

	'Clean up

	set pkg = nothing

	Main = DTSTaskExecResult_Success
End Function