[AccessD] Archiving files with Winzip Command Line version

Mcgillivray, Don [ITS] donald.a.Mcgillivray at mail.sprint.com
Wed Mar 9 11:41:03 CST 2005


Hello, All

In my app I'm archiving text files via VBA using the Winzip command line
and the ShellWait function I got from Dev Ashish's web site.  It works
well, but I need to be able to validate that the zip succeeds before
moving on to the next step in my code.  I've been experimenting with a
sample I found that uses the Windows Script Host.  Passing my Winzip
command line string to it causes the process to hang.  (The same string
passed to ShellWait works in a flash.)  I tried it using a command line
string for "Blat" to send a test email, and that worked as expected - no
hang.  A code sample is below.  Am I overlooking something?  Has anybody
a better solution for this requirement?

Thanks!

Don

Function GetErrorLevel()
  Dim wsShell As Object, Proc As Object, strCommand As String,
strErrLevel As String
  Dim strZipFileName As String, strTargetFile as String, strWinzipPath
as String
  
  strWinzipPath = "C:\Archive\Winzip\WZZIP"
  strZipFileName = "C:\Archive\TestZipFile.zip"
  strTargetFile = "C:\Data\DM02TEST.txt"

  strCommand =  strWinzipPath & " -a " & """" & strZipFileName & """" &
" " & """" & strTargetFile & """"

  'Testing command line using ShellWait
  'ShellWait strCommand, vbHide
  
  Set wsShell = CreateObject("wscript.shell")
  Set Proc = wsShell.Exec(strCommand)

  Do While Proc.Status = 0
     DoEvents 'Yields execution so that the operating system can process
other events
  Loop

  'Use proc.ExitCode to check for returned %errorlevel%
  strErrLevel = "StdOut=" & Proc.StdOut.ReadAll()
  strErrLevel = strErrLevel & Chr(13) & Chr(10) & "ExitCode=" &
Proc.ExitCode

  MsgBox (strErrLevel)

  Set wsShell = Nothing
  Set Proc = Nothing

End Function




More information about the AccessD mailing list