Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 1st, 2003, 10:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default File Compression: Automation

My goal is to automate the functionality of WinZip from within a Visual Basic 6.0 application.

In my efforts I have created a dll as a wrapper to the WinZip utility. The initial results
appeared to work well. The program uses the WinZip Command Line Add-On, a beta release, and WinZip 9.0 a beta release also. Initially I had used the Windows Scripting Host Object (WSHom) to make the calls to the command line. But, we experienced problems when the file name exceeded 15 characters. Not a problem for new releases but this application has to work with legacy files as well. When investigating a resolution I now understand the Windows Scripting Host cannot handle long file name. Also, the API ShortPathName( ) only returns a value if a file already exist. I read that if you enclose the command in double quotation marks the WSHom will accept it. But I was unable to get that to execute anything?

Since then I have changed the application to use the Shell( ) function. It appears to be working only about half of the time with various errors. WinZip itself never returns any errors? These are the two problems I have been encountering.

1. WinZip will execute but no file will be made. I have noticed this when executed within a For loop. To try and resolve this issue I have added a function to check for the existence of the file prior to executing the next loop. This has added considerable time to our application but seemed to resolve the situation minus the following problem.

2. WinZip will create the zipped file however the original file is not in the zipped file and
the file size is 0 kb.

Perhaps I have misunderstood the purpose of the utility.

Here are some samples of the command line arguments being executed:

' The following code is only for reference purposes
' The actual code is dynamic but this should enable you
' to better understand what is happening in the program

Dim lError as Long
Dim dX as Double
Dim strArg as String
Dim ws As WshShell ' Reference wshom.ocz

' Successful command using WSHom.ocx
strARG = "COMMAND.COM /C C:\PROGRA~1\WinZip\wzzip.exe -ee -o -jhrs" & Chr(34) & "C:\Temp\Vault\5108889510889.dwg.zip" & Chr(34) & "C:\Larry\COPYOF~1\5108889510889.dwg"

lError = ws.Run(strArg, vbMinimizedNoFocus, True)

' Failed command using WSHom.ocx
strARG = "COMMAND.COM /C C:\PROGRA~1\WinZip\wzzip.exe -ee -o -jhrs" & Chr(34) & "C:\Temp\Vault\51088895108890.dwg.zip" & Chr(34) & "C:\Larry\COPYOF~1\51088895108890.dwg"

lError = ws.Run(strArg, vbMinimizedNoFocus, True)

' Command executed using the shell function
strArg = "C:\PROGRA~1\WinZip\wzzip.exe -ee -o -jhrs" & Chr(34) &
"C:\Temp\Vault\51088895108890.dwg.zip" & Chr(34) & C:\Larry\COPYOF~1\51088895108890.dwg"

dx = Shell(strArg, vbMinimizedNoFocus)

Please offer your advise. At this point I am looking to either resolve the issue with
the Windows Scripting Host Object. But I am more inclined to look at an alternative to
WinZip.

Thanks in advance for your help,


Larry Asher
__________________
Larry Asher
 
Old July 2nd, 2003, 07:31 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Larry,

Try changing your command line to this:
strArg = Chr(34) & "C:\PROGRA~1\WinZip\wzzip.exe" & Chr(34) & " -ee -o -jhrs " & Chr(34) &
"C:\Temp\Vault\51088895108890.dwg.zip" & Chr(34) & " " & Chr(34) & "C:\Larry\COPYOF~1\51088895108890.dwg" & Chr(34)

 
Quote:
quote:' Command executed using the shell function
Quote:
strArg = "C:\PROGRA~1\WinZip\wzzip.exe -ee -o -jhrs" & Chr(34) &
"C:\Temp\Vault\51088895108890.dwg.zip" & Chr(34) & C:\Larry\COPYOF~1\51088895108890.dwg"

dx = Shell(strArg, vbMinimizedNoFocus)
And Other thing, remenber that Shell start the program asynchronously.

Stéphane
 
Old July 3rd, 2003, 08:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have tried that and several other variations. The only way I can get the command to execute is by shortening the filename.

Larry Asher
 
Old July 3rd, 2003, 08:35 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've try it and it work perfectly on my computer and I'm using the same version of WinZip.
Have you check if you have all the permission required for this?

Stéphane





Similar Threads
Thread Thread Starter Forum Replies Last Post
tiff compression sandrina C# 2005 1 December 4th, 2013 02:42 AM
File Compression: Automation xgbnow Pro VB 6 7 November 4th, 2008 06:22 AM
compression jaya_malini Java GUI 0 May 5th, 2005 10:01 AM
wav compression jothi Pro VB 6 0 April 26th, 2005 02:12 AM
Automation file not supported in visual basic sush_blr Beginning VB 6 2 December 28th, 2004 02:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.