Active X Script 'functon not found' error

  • Hi All,

    I am using the following Active X script below to unzip files from a location and extract them to another folder.

    '**********************************************************************

    ' Visual Basic ActiveX Script

    Function Main()

    Set oApp = CreateObject("Shell.Application")

    oApp.Namespace("C:\test").CopyHere oApp.Namespace("C:\test\test.zip").items

    End Function

    ---------------------------------------------------------------------

    so can anybody help me out how i can unzip files with windows shell utility.

    Thanks

    Allimina

  • First of all, you shouldn't be using the Active X Script component at all. This component exists only for backward compatibility with DTS.

    Instead, you should be using a Script Task.

    Search this forum for "unzip". You'll find a number of examples that give you the code to place in a Script Task.

  • Thank you sir for your reply.

    I also tried using through script task with following code below.

    But is not validating the task. saying Binary code for the script is missing. Can you please help me with this script.

    Thanks in advance

    allimina

    ======================================================

    ' Microsoft SQL Server Integration Services Script Task

    ' Write scripts using Microsoft Visual Basic 2008.

    ' The ScriptMain is the entry point class of the script.

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    Imports System.IO

    Imports Shell32

    _

    _

    Partial Public Class ScriptMain

    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

    Enum ScriptResults

    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success

    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

    End Enum

    ' The execution engine calls this method when the task executes.

    ' To access the object model, use the Dts property. Connections, variables, events,

    ' and logging features are available as members of the Dts property as shown in the following examples.

    '

    ' To reference a variable, call Dts.Variables("MyCaseSensitiveVariableName").Value

    ' To post a log entry, call Dts.Log("This is my log text", 999, Nothing)

    ' To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, True)

    '

    ' To use the connections collection use something like the following:

    ' ConnectionManager cm = Dts.Connections.Add("OLEDB")

    ' cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;"

    '

    ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

    '

    ' To open Help, press F1.

    Private Sub Button303_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button303.Click

    ' Unzip Variables

    Dim UserShell As Shell32.IShellDispatch2

    Dim ZipContent As Shell32.FolderItems

    Dim ExportLocation As Shell32.Folder

    ' -----------------------------------------------

    ' Unzip File -> only XP ?!

    ' -----------------------------------------------

    If File.Exists("C:\Inbound\ZZZ.zip") = False Then

    ' error mesage

    End If

    UserShell = CType(CreateObject("Shell.Application"), IShellDispatch2)

    ' if you like, you can get some properties of your content

    ' for ex. filenames?

    ZipContent = UserShell.NameSpace(("C:\Inbound\ZZZ.zip")).Items

    Dim i As Integer

    Dim Filename As String

    For i = 0 To ZipContent.Count - 1

    Filename = ZipContent.Item(i).Name.ToString

    Next

    ' unpack the thing

    ExportLocation = UserShell.NameSpace(("C:\SrcFiles\"))

    If ExportLocation IsNot Nothing Then

    ExportLocation.CopyHere(UserShell.NameSpace(("C:\Inbound\ZZZ.zip")).Items)

    End If

    End Sub

    End Class

  • You have a sub called Button303_Click with no obvious means by which it will ever be executed - where did this code come from, a Windows Forms VB.NET project, perhaps?

    You need something 'tuned' for SSIS & I would have thought (though I haven't checked) that there would be something more suitable on this forum.


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply