[AccessD] Archiving files with Winzip Command Line version

Andy Lacey andy at minstersystems.co.uk
Wed Mar 9 12:36:47 CST 2005


Don
You could use Dir in a loop to test for the zip existing. You'd have to Kill
the file before too. Then set a time limit and drop out of the loop if the
zip still didn't exist after that time.

-- Andy Lacey
http://www.minstersystems.co.uk 

> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com 
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of 
> Mcgillivray, Don [ITS]
> Sent: 09 March 2005 17:41
> To: AccessD
> Subject: [AccessD] Archiving files with Winzip Command Line version
> 
> 
> 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
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com 
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 
> 




More information about the AccessD mailing list