Problems with ActiveX and WScript.Shell

  • I have a problem with a program that itterates through a directory tree and unzips a WinZIP archive.

    Sub UnzipFileForExport  (ByVal newFile)
             
    
    'Build command args string for Winzip utility and run command line
    '*****************************************************************************
    execString = "wzunzip -d " & newFile.Path & " " & tempDirectory
    
    Set objShell = CreateObject("WScript.Shell")
    Set objScriptExec = objShell.Exec(execString)
    
    'Wait for unzip process
    '**************************
    While objScriptExec.Status <=0
    for x=0 to 10000
    next
    Wend
    
    ...etc
    

    The WinZIP files contains a single CSV file.

    For CSV files of less than 32,000 records WinZIP the program successfully unzips the archive.

    During the unzip a Windows command window opens but displays nothing then terminates.

    Where the CSV file is larger than 32,000 records the WinZIP program simply freezes with the windows command window open but with no messages whatsoever. Terminating the unzip allows the DTS to continue and process what few records have been unzipped but I am at a loss to diagnose the fault.

    I have tried logging the winzip command out to a file but when this is issued from the command prompt it always works as expected.

    I could understand a total failure to unzip but not a partial unzip.

  • Your problem sounds interesting. The number of records in the CSV should have no bearing on the unzip process, unless there is a file size issue. But I can't imagine a CSV with 32,000 records being that large. Is the ZIP file located on a network share? Perhaps a possible network issue?

    Have you tried using the StdOut Property to parse the output of the Exec command?  This might give you more insight as to what is causing the issue. Here's Microsoft's reference in case you need it:

    http://msdn.microsoft.com/library/en-us/script56/html/85684a76-6d66-4a1a-a3c4-cf3f48baa595.asp?frame=true

    Good luck!

  • The ZIP is on a local drive.

    I will try and use StdOut but I am not optimistic.

  • try using the run method

    Method:  WshShell.Run


    WshShell.Run strCommand [,intWindowStyle] [,bWaitOnReturn]

    The Run method creates a new process and runs the command specified by strCommand. The optional parameter intWindowStyle is used to set the window style of the program being run. If the optional parameter bWaitOnReturn is set to True (default is False), then Run will return the return value returned by strCommand. Otherwise it returns 0. Also, if bWaitOnReturn is set to True, then the script will suspend its execution until strCommand finishes.

  • I was doing something similar yesterday

    UnzipCommand = "%comspec% /c Bin\7za.exe e -y  " &  File2

    OBJShell.Run(UnzipCommand) ,1,TRUE

    The /c after comspec tell it to wait for the .exe to end. The TRUE on OBJShell.Run stops collission between different .Run commands.

    Best ref I found is here

    http://www.microsoft.com/technet/scriptcenter/guide/sas_scr_iikh.mspx

     

     

     

     

     

     

     

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

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