Consulting

Results 1 to 7 of 7

Thread: Run a Winzip self extracting file

  1. #1

    Run a Winzip self extracting file

    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.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Quote Originally Posted by mdmackillop
    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!

  4. #4
    Quote Originally Posted by Sam8932
    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!

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can you post your actual code.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    -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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  7. #7
    Quote Originally Posted by mdmackillop
    Can you post your actual code.
    Code to zip files CMS.xls and files in Content folder

    [vba]
    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
    [/vba]
    Code to create self extracting zip file:

    [vba]
    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
    [/vba]
    Code to run self-extracting zip file

    [vba]
    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
    [/vba]
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •