Scripting the Web Server Log Import DTS Task

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The following script creates and runs the Web Server Log Import DTS task. You can use this script in two ways to create a package that contains the DTS task to run:

  • You can run the package on the command line by using the command DTSRun.exe. The file DTSRun.exe is automatically installed on your server when you install SQL Server.

  • You can copy the script into a Visual Basic script (.vbs) file and run it by using CScript as follows:

    [drive]:cscriptfilename.vbs

For a description of the Web Server Log Import DTS task, see Commerce Server DTS Tasks.

'******************************************************************
' Web Server Log Import DTS Task
' This script creates a DTS package and runs it.
'******************************************************************
Dim oPackage 
Dim oTask 
Dim oStep 
Dim oProps 
Dim oTaskProps 
set oPackage = WScript.CreateObject("DTS.Package")

'******************************************************************
' Define package properties.
'******************************************************************
oPackage.Name = "Web Server Log Import Task"
oPackage.Description = "Defines and imports Web log files."

'******************************************************************
' Create a task.
'******************************************************************
Set oTask = oPackage.Tasks.New("Commerce.DTSLogImport")
oTask.Name = "Task1"
oTask.Description = "Creates a task for WebLogImport DTS"
Set oTaskProps = oTask.Properties

'*******************************************************************
' Set Web Server Log Import DTS task properties.
'*******************************************************************
oTaskProps("SourceName").value = "BlankSite"
oTaskProps("SourceType").value = 0

'ReadInfoFromAdmin property is:
'True if log import files are to be selected automatically from the log file directory for each Web server.
'False if log import files are to be specified manually. 

oTaskProps("ReadInfoFromAdmin").value = True
oTaskProps("ImportAllLogsSinceLastImport").value = TRUE

'*******************************************************************
' Set the log file path.
'*******************************************************************
'This property is used if the ReadInfoFromAdmin = True. It is ignored otherwise.
Dim vData
ReDim vData(0)
vData(0) = "LDS for MachineXYZ/Default Web Site|C:\LogFilePath\ex990402.log"
oTaskProps("VLogFileInfo").Value = vData
oPackage.Tasks.Add oTask

' ******************************************************************
' Create a step.
' ******************************************************************
Set oStep = oPackage.Steps.New
oStep.Name = "Step1"
oStep.TaskName = "Task1"

' For custom tasks written in Visual Basic, the steps cannot run on a 
' secondary thread.
oStep.ExecuteInMainThread = True
oPackage.Steps.Add oStep

' ******************************************************************
' Execute the package.
' ******************************************************************
oPackage.Execute
    For I = 1 To oPackage.Steps.Count
        If oPackage.Steps(I).ExecutionResult = 1 Then
            iStatus = False
            MsgBox oPackage.Steps(I).Name + " in the " + _ 
            oPackage.Name + " failed."
        End If
    Next 

MsgBox oPackage.Name + " Done"

Set oStep = Nothing
Set oTaskProps = Nothing
Set oProps = Nothing
Set oTaskProps = Nothing
Set oPackage = Nothing

See Also

Other Resources

DTSLogImport Object

Commerce Server DTS Tasks

Scripting DTS Tasks