Log in

View Full Version : Run a Winzip self extracting file



Sam8932
03-20-2007, 09:08 AM
I used Winzip to zip up files that we need to send to many users in different locations. The file created is an .exe file. These users do not have Winzip installed on their computers. Is there a way to run this executable winzip file on the users machine with VBA code? I am using a Shell command to zip the files. If the users had Winzip installed on their computers there would be no problem. What I need to do is extract the files to different locations on the users PCand I'm not sure how to do that. As far as passing in parameters and such. Could you post some code on how to run the .exe file to extract specific files to specific locations on a users PC?

Hopefully I've given you enough info.

Thanks in advance.

mdmackillop
03-20-2007, 11:10 AM
Hi Sam,
Welcome to VBAX
As I recall, you can create a self extracting exe file with WinZip, which will extract to locations you determine. This is all part of your Zipping procedure. A Shell command can be used to run the exe, to extract to the predetermined locations.
Regards
MD

Sam8932
03-20-2007, 11:18 AM
Hi Sam,
Welcome to VBAX
As I recall, you can create a self extracting exe file with WinZip, which will extract to locations you determine. This is all part of your Zipping procedure. A Shell command can be used to run the exe, to extract to the predetermined locations.
Regards
MD

Thanks for the reply MD. I think I'm getting close to what you're talking about.

Here's what I have so far but I still can't get it to work.

wkCmnd = "" & strZipFileLocation & " """ & strZipFile & """ """ & " -d " & strUnzipLocation & """"

strZipFileLocation = C:\Program Files\WinZip Self-Extractor\wzipse32

strZipFile = "C:\cms\Desktop\Cont_DB_Testing_Folder\Bryce App\CMS_Data.zip"

strUnzipLocation = " -d C:\content" (The default "Unzip To" folder)

Here's how it reads out in the Immediate window.

C:\Program Files\WinZip Self-Extractor\wzipse32.exe "C:\cms\Desktop\Cont_DB_Testing_Folder\Bryce App\CMS_Data.zip" " -d C:\content"

I'm getting an error saying: "zip file name already specified - "" -d C:\content"" ignored!

Any idea what I may have wrong?

Thanks agian for the help!

Sam8932
03-20-2007, 11:45 AM
Thanks for the reply MD. I think I'm getting close to what you're talking about.

Here's what I have so far but I still can't get it to work.

wkCmnd = "" & strZipFileLocation & " """ & strZipFile & """ """ & " -d " & strUnzipLocation & """"

strZipFileLocation = C:\Program Files\WinZip Self-Extractor\wzipse32

strZipFile = "C:\cms\Desktop\Cont_DB_Testing_Folder\Bryce App\CMS_Data.zip"

strUnzipLocation = " -d C:\content" (The default "Unzip To" folder)

Here's how it reads out in the Immediate window.

C:\Program Files\WinZip Self-Extractor\wzipse32.exe "C:\cms\Desktop\Cont_DB_Testing_Folder\Bryce App\CMS_Data.zip" " -d C:\content"

I'm getting an error saying: "zip file name already specified - "" -d C:\content"" ignored!

Any idea what I may have wrong?

Thanks agian for the help!


I think I may have figured it out.

wkCmnd = "" & strZipFileLocation & " """ & strZipFile & """ " & " -d " & strUnzipLocation & ""

now reads in the Immediate window as:
C:\Program Files\WinZip Self-Extractor\wzipse32.exe "C:\cms\Desktop\Cont_DB_Testing_Folder\Bryce App\CMS_Data" -d C:\content

I just have to figure out how to avoid the prompt that comes up asking whether to overwrite the existing file as we will run this twice a week and don't plan on deleting the original file.

Thanks again!

mdmackillop
03-20-2007, 12:10 PM
Can you post your actual code.

mdmackillop
03-20-2007, 12:13 PM
-o[-] Overwrite existing files without a prompt (automatically reply "Yes" to each overwrite prompt). Use the optional "-" suffix to automatically reply "No" to each overwrite prompt.
wzunzip -o "c:\my documents\spring2005.zip" c:\semesters\spring05
Extract all files from the Zip file c:\my documents\spring2005.zip into c:\semesters\spring05 including those files with the same name as files that already exists in that folder.
wzunzip -o- "c:\my documents\spring2005.zip" c:\semesters\spring05

Extract all files from the Zip file c:\my documents\spring2005.zip into c:\semesters\spring05 except those files with the same name as files that already exists in that folder.

Sam8932
03-20-2007, 12:30 PM
Can you post your actual code.
Code to zip files CMS.xls and files in Content folder


Private Sub Command465_Click()
Dim strZipFile As String
Dim strFilePath As String
Dim strScriptsFile As String
Dim strContentFolder As String
Dim strZipFileLocation As String

strFilePath = GetDBPath

strZipFile = strFilePath & "CMS_Data.zip"

strScriptsFile = strFilePath & "CMS.XLS"

strContentFolder = strFilePath & "content\*.*"

strZipFileLocation = LocateFile("wzzip.exe")

'adding CMS.xls file
wkCmnd = "" & strZipFileLocation & " -a" & " """ & strZipFile & """ """ & strScriptsFile & """"
intZipVal = Shell(wkCmnd, vbMaximizedFocus)

If intZipVal = 0 Or Err.Number = 53 Then
MsgBox "Could not Create ZIP File"
End If

'adding Contents folder
wkCmnd = "" & strZipFileLocation & " -u" & " """ & strZipFile & """ """ & strContentFolder & """"
intZipVal = Shell(wkCmnd, vbMaximizedFocus)

If intZipVal = 0 Or Err.Number = 53 Then
MsgBox "Could not Create ZIP File"
End If

End Sub

Code to create self extracting zip file:


Private Sub Command467_Click()
Dim strFilePath As String
Dim strZipFileLocation As String
Dim strUnzipLocation As String
Dim strZipFile As String

strFilePath = GetDBPath

strZipFileLocation = LocateFile("wzipse32.exe")

strUnzipLocation = "C:\content"

strZipFile = strFilePath & "CMS_Data"

wkCmnd = "" & strZipFileLocation & " """ & strZipFile & """ " & " -y -auto -d " & strUnzipLocation & ""
intZipVal = Shell(wkCmnd, vbMaximizedFocus)
End Sub

Code to run self-extracting zip file


Private Sub Command466_Click()
Dim strZipFile As String
Dim strFilePath As String
Dim strZipFileLocation As String

strFilePath = GetDBPath

strZipFile = strFilePath & "CMS_Data.exe"

strZipFileLocation = LocateFile("wzunzip.exe")
Retval = Shell(strZipFile, 0)

End Sub

The code isn't very polished as I'm still in the testing phase.

Edit to add: I still have to test the code that runs the self executable on a machine that doesn't have Winzip installed on it.