xp_cmdshell winzip

  • hello

    I have this cmd

    declare @cmd varchar(2000)

    select @cmd

    = 'C:\"Program Files (x86)"\WinZip\wzzip.exe' + ' -whs ' + ' -ez ' + ' -rP ' + 'F:\restore\testfile.zip' + ' ' + 'F:\restore\abc.txt > C:\output.log'

    print @cmd

    exec master..xp_cmdshell @cmd

    (http://kb.winzip.com/kb/entry/166/)

    But it never overwrites output file. I tried with -o switch as well but its not overwriting. I have winzip 12.0. Can someone please tell me how to do that?

  • i think the double quotes have to be around the entire path to the wzzip.exe file, not just *part* of the file name:

    declare @cmd varchar(2000)

    select @cmd

    = '"C:\Program Files (x86)\WinZip\wzzip.exe"' + ' -whs ' + ' -ez ' + ' -rP ' + 'F:\restore\testfile.zip' + ' ' + 'F:\restore\abc.txt > C:\output.log'

    print @cmd

    exec master..xp_cmdshell @cmd

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • okay thanks for the reply but when I ran the same script 5 times after 5 minutes interval, it overwrite the files every time.

    Here is what it says,

    WinZip(R) Command Line Support Add-On Version 3.0 (Build 8252)

    Copyright (c) 1991-2008 WinZip International LLC - All Rights Reserved

    Updating restore\abc.txt

    Updating Zip file F:\restore\testfile.zip

    IT should NOT overwrite.

  • dallas13 (4/28/2011)


    okay thanks for the reply but when I ran the same script 5 times after 5 minutes interval, it overwrite the files every time.

    Here is what it says,

    WinZip(R) Command Line Support Add-On Version 3.0 (Build 8252)

    Copyright (c) 1991-2008 WinZip International LLC - All Rights Reserved

    Updating restore\abc.txt

    Updating Zip file F:\restore\testfile.zip

    IT should NOT overwrite.

    If you give winzip a specific filename, it will overwrite it. You told it what to do, and it did it, so what you need to do is use one of the options to generate a unique filename instead.

    take a look at this command line syntax pdf for winzip:

    http:/www.lexjansen.com/phuse/2006/cc/cc01.pdf

    i think you want to generate the unique filename yourself.

    you could try the extra parameters with winzip, but i never tried that:

    ADD_DATETIME

    This parameter is used to include a date/time suffix to the zip file name. By default this

    functionality is not activated. To activate, then specify ‘Y’. The suffix is in the form

    ‘_YYYYMMDDHHMMSS’ (translating to year,month,day,hour,minute,seconds). This is

    useful when you want to provide a unique zip file name.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply