Compressed (zipped) Folder - command line variant?

Archived from groups: microsoft.public.windowsxp.general (More info?)

Is there any way to create a zipped folder from the command line? "Compact"
doesn't really do what I want (just uses drivespace or something to compress
the folder).

What I'm trying to do is make a simple batch file that creates a folder,
throws a bunch of files with the same extenstion into it, and then zips it
up- but without a command line version of the built-in windows zip program
this will be impossible (through batch file anyway). Any ideas?
9 answers Last reply
More about compressed zipped folder command line variant
  1. Archived from groups: microsoft.public.windowsxp.general (More info?)

    You can download the below app and create ZIP files using the BAT
    feature if you know how. PKZip uses the command line.
    PKZIP, PKUNZIP, WINZIP 9.0 - ZIP File Utilities (Shareware)
    http://www.interpages.co.uk/pkzipage/
    --
    Some days you're the windshield,
    some days you're the bug.


    "Tempest261" wrote:

    > Is there any way to create a zipped folder from the command line? "Compact"
    > doesn't really do what I want (just uses drivespace or something to compress
    > the folder).
    >
    > What I'm trying to do is make a simple batch file that creates a folder,
    > throws a bunch of files with the same extenstion into it, and then zips it
    > up- but without a command line version of the built-in windows zip program
    > this will be impossible (through batch file anyway). Any ideas?
  2. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Yeah, the problem is that I didn't want to force the user to install/copy
    pkzip onto their computer.

    "Byte" wrote:

    > You can download the below app and create ZIP files using the BAT
    > feature if you know how. PKZip uses the command line.
    > PKZIP, PKUNZIP, WINZIP 9.0 - ZIP File Utilities (Shareware)
    > http://www.interpages.co.uk/pkzipage/
    > --
    > Some days you're the windshield,
    > some days you're the bug.
    >
    >
    > "Tempest261" wrote:
    >
    > > Is there any way to create a zipped folder from the command line? "Compact"
    > > doesn't really do what I want (just uses drivespace or something to compress
    > > the folder).
    > >
    > > What I'm trying to do is make a simple batch file that creates a folder,
    > > throws a bunch of files with the same extenstion into it, and then zips it
    > > up- but without a command line version of the built-in windows zip program
    > > this will be impossible (through batch file anyway). Any ideas?
  3. Archived from groups: microsoft.public.windowsxp.general (More info?)

    This script extracts files from a zip passed on the command line and makes a folder on the desktop with the contents. Just do reverse to zip. A new zip file is easly created (look at a new one - it's 14 bytes of mostly null but starting PK). This uses Shell commands rather than File commands. We are working with shell objects that merely happen to be files.

    Set objShell = CreateObject("Shell.Application")
    Set Ag=Wscript.Arguments
    set WshShell = WScript.CreateObject("WScript.Shell")


    Set DestFldr=objShell.NameSpace(Ag(1))
    Set SrcFldr=objShell.NameSpace(Ag(0))
    Set FldrItems=SrcFldr.Items
    DestFldr.CopyHere FldrItems, &H214


    I specified options of 0x214 (&h214) in hex. 200 + 10 + 4, change to suit your purposes.

    Private Const FO_MOVE As Long = &H1
    Private Const FO_COPY As Long = &H2
    Private Const FO_DELETE As Long = &H3
    Private Const FO_RENAME As Long = &H4

    Private Const FOF_MULTIDESTFILES As Long = &H1
    Private Const FOF_CONFIRMMOUSE As Long = &H2
    Private Const FOF_SILENT As Long = &H4
    Private Const FOF_RENAMEONCOLLISION As Long = &H8
    Private Const FOF_NOCONFIRMATION As Long = &H10
    Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
    Private Const FOF_CREATEPROGRESSDLG As Long = &H0
    Private Const FOF_ALLOWUNDO As Long = &H40
    Private Const FOF_FILESONLY As Long = &H80
    Private Const FOF_SIMPLEPROGRESS As Long = &H100
    Private Const FOF_NOCONFIRMMKDIR As Long = &H200

    FlagDescription
    FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
    FOF_CONFIRMMOUSENot currently used.
    FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
    FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
    FOF_NOCONFIRMATION Respond with "Yes to All" for any dialog box that is displayed.
    FOF_NOCONFIRMMKDIR Do not confirm the creation of a new directory if the operation requires one to be created.
    FOF_NO_CONNECTED_ELEMENTSVersion 5.0. Do not move connected files as a group. Only move the specified files.
    FOF_NOCOPYSECURITYATTRIBSVersion 4.71. Do not copy the security attributes of the file.
    FOF_NOERRORUI Do not display a user interface if an error occurs.
    FOF_NORECURSIONOnly operate in the local directory. Don't operate recursively into subdirectories.
    FOF_RECURSEREPARSERecurse into reparse points. The default is to not recurse.
    FOF_NORECURSEREPARSETreat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
    FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
    FOF_SILENT Do not display a progress dialog box.
    FOF_SIMPLEPROGRESS Display a progress dialog box but do not show the file names.
    FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
    FOF_WANTNUKEWARNINGVersion 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.


    --
    --------------------------------------------------------------------------------------------------
    http://webdiary.smh.com.au/archives/_comment/001075.html
    =================================================
    "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:603740A2-288A-4FE5-BCD4-FD1AC82C6298@microsoft.com...
    > Is there any way to create a zipped folder from the command line? "Compact"
    > doesn't really do what I want (just uses drivespace or something to compress
    > the folder).
    >
    > What I'm trying to do is make a simple batch file that creates a folder,
    > throws a bunch of files with the same extenstion into it, and then zips it
    > up- but without a command line version of the built-in windows zip program
    > this will be impossible (through batch file anyway). Any ideas?
  4. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Awesome! Thanks. I'll give that a try.

    "David Candy" wrote:

    > This script extracts files from a zip passed on the command line and makes a folder on the desktop with the contents. Just do reverse to zip. A new zip file is easly created (look at a new one - it's 14 bytes of mostly null but starting PK). This uses Shell commands rather than File commands. We are working with shell objects that merely happen to be files.
    >
    > Set objShell = CreateObject("Shell.Application")
    > Set Ag=Wscript.Arguments
    > set WshShell = WScript.CreateObject("WScript.Shell")
    >
    >
    > Set DestFldr=objShell.NameSpace(Ag(1))
    > Set SrcFldr=objShell.NameSpace(Ag(0))
    > Set FldrItems=SrcFldr.Items
    > DestFldr.CopyHere FldrItems, &H214
    >
    >
    > I specified options of 0x214 (&h214) in hex. 200 + 10 + 4, change to suit your purposes.
    >
    > Private Const FO_MOVE As Long = &H1
    > Private Const FO_COPY As Long = &H2
    > Private Const FO_DELETE As Long = &H3
    > Private Const FO_RENAME As Long = &H4
    >
    > Private Const FOF_MULTIDESTFILES As Long = &H1
    > Private Const FOF_CONFIRMMOUSE As Long = &H2
    > Private Const FOF_SILENT As Long = &H4
    > Private Const FOF_RENAMEONCOLLISION As Long = &H8
    > Private Const FOF_NOCONFIRMATION As Long = &H10
    > Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
    > Private Const FOF_CREATEPROGRESSDLG As Long = &H0
    > Private Const FOF_ALLOWUNDO As Long = &H40
    > Private Const FOF_FILESONLY As Long = &H80
    > Private Const FOF_SIMPLEPROGRESS As Long = &H100
    > Private Const FOF_NOCONFIRMMKDIR As Long = &H200
    >
    > FlagDescription
    > FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
    > FOF_CONFIRMMOUSENot currently used.
    > FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
    > FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
    > FOF_NOCONFIRMATION Respond with "Yes to All" for any dialog box that is displayed.
    > FOF_NOCONFIRMMKDIR Do not confirm the creation of a new directory if the operation requires one to be created.
    > FOF_NO_CONNECTED_ELEMENTSVersion 5.0. Do not move connected files as a group. Only move the specified files.
    > FOF_NOCOPYSECURITYATTRIBSVersion 4.71. Do not copy the security attributes of the file.
    > FOF_NOERRORUI Do not display a user interface if an error occurs.
    > FOF_NORECURSIONOnly operate in the local directory. Don't operate recursively into subdirectories.
    > FOF_RECURSEREPARSERecurse into reparse points. The default is to not recurse.
    > FOF_NORECURSEREPARSETreat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
    > FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
    > FOF_SILENT Do not display a progress dialog box.
    > FOF_SIMPLEPROGRESS Display a progress dialog box but do not show the file names.
    > FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
    > FOF_WANTNUKEWARNINGVersion 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
    >
    >
    >
    >
    >
    > --
    > --------------------------------------------------------------------------------------------------
    > http://webdiary.smh.com.au/archives/_comment/001075.html
    > =================================================
    > "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:603740A2-288A-4FE5-BCD4-FD1AC82C6298@microsoft.com...
    > > Is there any way to create a zipped folder from the command line? "Compact"
    > > doesn't really do what I want (just uses drivespace or something to compress
    > > the folder).
    > >
    > > What I'm trying to do is make a simple batch file that creates a folder,
    > > throws a bunch of files with the same extenstion into it, and then zips it
    > > up- but without a command line version of the built-in windows zip program
    > > this will be impossible (through batch file anyway). Any ideas?
    >
  5. Archived from groups: microsoft.public.windowsxp.general (More info?)

    David,

    I tried that script and ran into a few problems. I wanted to first try it in
    its original format, so I copied and pasted the top portion. I have some
    programming experience but skipped the whole shell scripting phase, so I just
    assumed that you needed the private constants and the top part of the
    program, minus the parts that are obviously not code.

    The command line didn't like the constants, so I figured those might be
    built in, and then it accepted most of the script except for the last part-
    "DestFldr.CopyHere FldrItems, &H214" gave me the error:

    & H214 ' DestFldr.CopyHere' is not recognized as an internal or external
    command, operable program or batch file. 'H214' is not recognized as an
    internal or external command, operable program or batch file.

    Any ideas?

    Thanks,
    Mike


    "David Candy" wrote:

    > This script extracts files from a zip passed on the command line and makes a folder on the desktop with the contents. Just do reverse to zip. A new zip file is easly created (look at a new one - it's 14 bytes of mostly null but starting PK). This uses Shell commands rather than File commands. We are working with shell objects that merely happen to be files.
    >
    > Set objShell = CreateObject("Shell.Application")
    > Set Ag=Wscript.Arguments
    > set WshShell = WScript.CreateObject("WScript.Shell")
    >
    >
    > Set DestFldr=objShell.NameSpace(Ag(1))
    > Set SrcFldr=objShell.NameSpace(Ag(0))
    > Set FldrItems=SrcFldr.Items
    > DestFldr.CopyHere FldrItems, &H214
    >
    >
    > I specified options of 0x214 (&h214) in hex. 200 + 10 + 4, change to suit your purposes.
    >
    > Private Const FO_MOVE As Long = &H1
    > Private Const FO_COPY As Long = &H2
    > Private Const FO_DELETE As Long = &H3
    > Private Const FO_RENAME As Long = &H4
    >
    > Private Const FOF_MULTIDESTFILES As Long = &H1
    > Private Const FOF_CONFIRMMOUSE As Long = &H2
    > Private Const FOF_SILENT As Long = &H4
    > Private Const FOF_RENAMEONCOLLISION As Long = &H8
    > Private Const FOF_NOCONFIRMATION As Long = &H10
    > Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
    > Private Const FOF_CREATEPROGRESSDLG As Long = &H0
    > Private Const FOF_ALLOWUNDO As Long = &H40
    > Private Const FOF_FILESONLY As Long = &H80
    > Private Const FOF_SIMPLEPROGRESS As Long = &H100
    > Private Const FOF_NOCONFIRMMKDIR As Long = &H200
    >
    > FlagDescription
    > FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
    > FOF_CONFIRMMOUSENot currently used.
    > FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
    > FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
    > FOF_NOCONFIRMATION Respond with "Yes to All" for any dialog box that is displayed.
    > FOF_NOCONFIRMMKDIR Do not confirm the creation of a new directory if the operation requires one to be created.
    > FOF_NO_CONNECTED_ELEMENTSVersion 5.0. Do not move connected files as a group. Only move the specified files.
    > FOF_NOCOPYSECURITYATTRIBSVersion 4.71. Do not copy the security attributes of the file.
    > FOF_NOERRORUI Do not display a user interface if an error occurs.
    > FOF_NORECURSIONOnly operate in the local directory. Don't operate recursively into subdirectories.
    > FOF_RECURSEREPARSERecurse into reparse points. The default is to not recurse.
    > FOF_NORECURSEREPARSETreat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
    > FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
    > FOF_SILENT Do not display a progress dialog box.
    > FOF_SIMPLEPROGRESS Display a progress dialog box but do not show the file names.
    > FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
    > FOF_WANTNUKEWARNINGVersion 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
    >
    >
    >
    >
    >
    > --
    > --------------------------------------------------------------------------------------------------
    > http://webdiary.smh.com.au/archives/_comment/001075.html
    > =================================================
    > "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:603740A2-288A-4FE5-BCD4-FD1AC82C6298@microsoft.com...
    > > Is there any way to create a zipped folder from the command line? "Compact"
    > > doesn't really do what I want (just uses drivespace or something to compress
    > > the folder).
    > >
    > > What I'm trying to do is make a simple batch file that creates a folder,
    > > throws a bunch of files with the same extenstion into it, and then zips it
    > > up- but without a command line version of the built-in windows zip program
    > > this will be impossible (through batch file anyway). Any ideas?
    >
  6. Archived from groups: microsoft.public.windowsxp.general (More info?)

    Tempest261 wrote:

    > David,
    >
    > I tried that script and ran into a few problems. I wanted to first try it in
    > its original format, so I copied and pasted the top portion. I have some
    > programming experience but skipped the whole shell scripting phase, so I just
    > assumed that you needed the private constants and the top part of the
    > program, minus the parts that are obviously not code.
    >
    > The command line didn't like the constants, so I figured those might be
    > built in, and then it accepted most of the script except for the last part-
    > "DestFldr.CopyHere FldrItems, &H214" gave me the error:
    >
    > & H214 ' DestFldr.CopyHere' is not recognized as an internal or external
    > command, operable program or batch file. 'H214' is not recognized as an
    > internal or external command, operable program or batch file.
    >
    > Any ideas?
    Hi,

    What David posted, was VBScript code, not a batch file. You need to
    put the code into a .vbs file, that you can access from command line,
    e.g. like this:

    cscript.exe "c:\my scripts\zip.vbs" "some input parameter"


    --
    torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
    Administration scripting examples and an ONLINE version of
    the 1328 page Scripting Guide:
    http://www.microsoft.com/technet/scriptcenter/default.mspx
  7. Archived from groups: microsoft.public.windowsxp.general (More info?)

    You cut and pasted it wrong.

    I've been playing with it and when zipping it often doesn't do anything. Poping up a dialog box makes it work. It could be a timing issue. But putting a msgbox at the end of the code always zips.

    unzip <folder or zip name to be copied from> <folder or zip name to copy to>
    unZip.vbs" "C:\Documents and Settings\David Candy\Desktop\test" "C:\Documents and
    Settings\David Candy\Desktop\AFDG_W.zip"


    Set objShell = CreateObject("Shell.Application")
    Set Ag=Wscript.Arguments
    set WshShell = WScript.CreateObject("WScript.Shell")

    Set DestFldr=objShell.NameSpace(Ag(1))
    Set SrcFldr=objShell.NameSpace(Ag(0))
    Set FldrItems=SrcFldr.Items
    DestFldr.CopyHere FldrItems, &H214
    Msgbox "Finished"


    --
    --------------------------------------------------------------------------------------------------
    http://webdiary.smh.com.au/archives/_comment/001075.html
    =================================================
    "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:709EDEB0-9BD7-48BF-8399-40E6AB1A74AF@microsoft.com...
    > David,
    >
    > I tried that script and ran into a few problems. I wanted to first try it in
    > its original format, so I copied and pasted the top portion. I have some
    > programming experience but skipped the whole shell scripting phase, so I just
    > assumed that you needed the private constants and the top part of the
    > program, minus the parts that are obviously not code.
    >
    > The command line didn't like the constants, so I figured those might be
    > built in, and then it accepted most of the script except for the last part-
    > "DestFldr.CopyHere FldrItems, &H214" gave me the error:
    >
    > & H214 ' DestFldr.CopyHere' is not recognized as an internal or external
    > command, operable program or batch file. 'H214' is not recognized as an
    > internal or external command, operable program or batch file.
    >
    > Any ideas?
    >
    > Thanks,
    > Mike
    >
    >
    > "David Candy" wrote:
    >
    >> This script extracts files from a zip passed on the command line and makes a folder on the desktop with the contents. Just do reverse to zip. A new zip file is easly created (look at a new one - it's 14 bytes of mostly null but starting PK). This uses Shell commands rather than File commands. We are working with shell objects that merely happen to be files.
    >>
    >> Set objShell = CreateObject("Shell.Application")
    >> Set Ag=Wscript.Arguments
    >> set WshShell = WScript.CreateObject("WScript.Shell")
    >>
    >>
    >> Set DestFldr=objShell.NameSpace(Ag(1))
    >> Set SrcFldr=objShell.NameSpace(Ag(0))
    >> Set FldrItems=SrcFldr.Items
    >> DestFldr.CopyHere FldrItems, &H214
    >>
    >>
    >> I specified options of 0x214 (&h214) in hex. 200 + 10 + 4, change to suit your purposes.
    >>
    >> Private Const FO_MOVE As Long = &H1
    >> Private Const FO_COPY As Long = &H2
    >> Private Const FO_DELETE As Long = &H3
    >> Private Const FO_RENAME As Long = &H4
    >>
    >> Private Const FOF_MULTIDESTFILES As Long = &H1
    >> Private Const FOF_CONFIRMMOUSE As Long = &H2
    >> Private Const FOF_SILENT As Long = &H4
    >> Private Const FOF_RENAMEONCOLLISION As Long = &H8
    >> Private Const FOF_NOCONFIRMATION As Long = &H10
    >> Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
    >> Private Const FOF_CREATEPROGRESSDLG As Long = &H0
    >> Private Const FOF_ALLOWUNDO As Long = &H40
    >> Private Const FOF_FILESONLY As Long = &H80
    >> Private Const FOF_SIMPLEPROGRESS As Long = &H100
    >> Private Const FOF_NOCONFIRMMKDIR As Long = &H200
    >>
    >> FlagDescription
    >> FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
    >> FOF_CONFIRMMOUSENot currently used.
    >> FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
    >> FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
    >> FOF_NOCONFIRMATION Respond with "Yes to All" for any dialog box that is displayed.
    >> FOF_NOCONFIRMMKDIR Do not confirm the creation of a new directory if the operation requires one to be created.
    >> FOF_NO_CONNECTED_ELEMENTSVersion 5.0. Do not move connected files as a group. Only move the specified files.
    >> FOF_NOCOPYSECURITYATTRIBSVersion 4.71. Do not copy the security attributes of the file.
    >> FOF_NOERRORUI Do not display a user interface if an error occurs.
    >> FOF_NORECURSIONOnly operate in the local directory. Don't operate recursively into subdirectories.
    >> FOF_RECURSEREPARSERecurse into reparse points. The default is to not recurse.
    >> FOF_NORECURSEREPARSETreat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
    >> FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
    >> FOF_SILENT Do not display a progress dialog box.
    >> FOF_SIMPLEPROGRESS Display a progress dialog box but do not show the file names.
    >> FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
    >> FOF_WANTNUKEWARNINGVersion 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
    >>
    >>
    >>
    >>
    >>
    >> --
    >> --------------------------------------------------------------------------------------------------
    >> http://webdiary.smh.com.au/archives/_comment/001075.html
    >> =================================================
    >> "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:603740A2-288A-4FE5-BCD4-FD1AC82C6298@microsoft.com...
    >> > Is there any way to create a zipped folder from the command line? "Compact"
    >> > doesn't really do what I want (just uses drivespace or something to compress
    >> > the folder).
    >> >
    >> > What I'm trying to do is make a simple batch file that creates a folder,
    >> > throws a bunch of files with the same extenstion into it, and then zips it
    >> > up- but without a command line version of the built-in windows zip program
    >> > this will be impossible (through batch file anyway). Any ideas?
    >>
  8. Archived from groups: microsoft.public.windowsxp.general (More info?)

    I can't get the script to work either.

    Here is my session copied from a DOS Window:

    ---
    D:\Vbs> type ZipTest.vbs
    Set objShell = CreateObject("Shell.Application")
    Set Ag=Wscript.Arguments
    set WshShell = WScript.CreateObject("WScript.Shell")

    Set DestFldr=objShell.NameSpace(Ag(1))
    Set SrcFldr=objShell.NameSpace(Ag(0))
    Set FldrItems=SrcFldr.Items
    DestFldr.CopyHere FldrItems, &H214
    Msgbox "Finished"

    D:\Vbs> dir c:\test
    Volume in drive C has no label.
    Volume Serial Number is A0FD-483A

    Directory of c:\test

    06/21/2005 17:06 <DIR> .
    06/21/2005 17:06 <DIR> ..
    06/21/2005 13:44 1,671,168 Track01 (2) .ISO
    06/21/2005 13:43 1,671,168 Track01.ISO
    06/21/2005 13:45 1,671,168 Track01.zip
    3 File(s) 5,013,504 bytes
    2 Dir(s) 125,554,696,192 bytes free

    D:\Vbs> cscript ZipTest.vbs c:\test c:\test\test.zip
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    D:\Vbs\ZipTest.vbs(8, 1) Microsoft VBScript runtime error:
    Object required: 'DestFldr'

    D:\Vbs>
    ---

    My intentions are to copy the files in c:\test to the zip file
    c:\test\test.zip.

    Any ideas?? TIA


    "David Candy" wrote:

    > You cut and pasted it wrong.
    >
    > I've been playing with it and when zipping it often doesn't do anything. Poping up a dialog box makes it work. It could be a timing issue. But putting a msgbox at the end of the code always zips.
    >
    > unzip <folder or zip name to be copied from> <folder or zip name to copy to>
    > unZip.vbs" "C:\Documents and Settings\David Candy\Desktop\test" "C:\Documents and
    > Settings\David Candy\Desktop\AFDG_W.zip"
    >
    >
    > Set objShell = CreateObject("Shell.Application")
    > Set Ag=Wscript.Arguments
    > set WshShell = WScript.CreateObject("WScript.Shell")
    >
    > Set DestFldr=objShell.NameSpace(Ag(1))
    > Set SrcFldr=objShell.NameSpace(Ag(0))
    > Set FldrItems=SrcFldr.Items
    > DestFldr.CopyHere FldrItems, &H214
    > Msgbox "Finished"
    >
    >
    >
    > --
    > --------------------------------------------------------------------------------------------------
    > http://webdiary.smh.com.au/archives/_comment/001075.html
    > =================================================
    > "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:709EDEB0-9BD7-48BF-8399-40E6AB1A74AF@microsoft.com...
    > > David,
    > >
    > > I tried that script and ran into a few problems. I wanted to first try it in
    > > its original format, so I copied and pasted the top portion. I have some
    > > programming experience but skipped the whole shell scripting phase, so I just
    > > assumed that you needed the private constants and the top part of the
    > > program, minus the parts that are obviously not code.
    > >
    > > The command line didn't like the constants, so I figured those might be
    > > built in, and then it accepted most of the script except for the last part-
    > > "DestFldr.CopyHere FldrItems, &H214" gave me the error:
    > >
    > > & H214 ' DestFldr.CopyHere' is not recognized as an internal or external
    > > command, operable program or batch file. 'H214' is not recognized as an
    > > internal or external command, operable program or batch file.
    > >
    > > Any ideas?
    > >
    > > Thanks,
    > > Mike
    > >
    > >
    > > "David Candy" wrote:
    > >
    > >> This script extracts files from a zip passed on the command line and makes a folder on the desktop with the contents. Just do reverse to zip. A new zip file is easly created (look at a new one - it's 14 bytes of mostly null but starting PK). This uses Shell commands rather than File commands. We are working with shell objects that merely happen to be files.
    > >>
    > >> Set objShell = CreateObject("Shell.Application")
    > >> Set Ag=Wscript.Arguments
    > >> set WshShell = WScript.CreateObject("WScript.Shell")
    > >>
    > >>
    > >> Set DestFldr=objShell.NameSpace(Ag(1))
    > >> Set SrcFldr=objShell.NameSpace(Ag(0))
    > >> Set FldrItems=SrcFldr.Items
    > >> DestFldr.CopyHere FldrItems, &H214
    > >>
    > >>
    > >> I specified options of 0x214 (&h214) in hex. 200 + 10 + 4, change to suit your purposes.
    > >>
    > >> Private Const FO_MOVE As Long = &H1
    > >> Private Const FO_COPY As Long = &H2
    > >> Private Const FO_DELETE As Long = &H3
    > >> Private Const FO_RENAME As Long = &H4
    > >>
    > >> Private Const FOF_MULTIDESTFILES As Long = &H1
    > >> Private Const FOF_CONFIRMMOUSE As Long = &H2
    > >> Private Const FOF_SILENT As Long = &H4
    > >> Private Const FOF_RENAMEONCOLLISION As Long = &H8
    > >> Private Const FOF_NOCONFIRMATION As Long = &H10
    > >> Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
    > >> Private Const FOF_CREATEPROGRESSDLG As Long = &H0
    > >> Private Const FOF_ALLOWUNDO As Long = &H40
    > >> Private Const FOF_FILESONLY As Long = &H80
    > >> Private Const FOF_SIMPLEPROGRESS As Long = &H100
    > >> Private Const FOF_NOCONFIRMMKDIR As Long = &H200
    > >>
    > >> FlagDescription
    > >> FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
    > >> FOF_CONFIRMMOUSENot currently used.
    > >> FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
    > >> FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
    > >> FOF_NOCONFIRMATION Respond with "Yes to All" for any dialog box that is displayed.
    > >> FOF_NOCONFIRMMKDIR Do not confirm the creation of a new directory if the operation requires one to be created.
    > >> FOF_NO_CONNECTED_ELEMENTSVersion 5.0. Do not move connected files as a group. Only move the specified files.
    > >> FOF_NOCOPYSECURITYATTRIBSVersion 4.71. Do not copy the security attributes of the file.
    > >> FOF_NOERRORUI Do not display a user interface if an error occurs.
    > >> FOF_NORECURSIONOnly operate in the local directory. Don't operate recursively into subdirectories.
    > >> FOF_RECURSEREPARSERecurse into reparse points. The default is to not recurse.
    > >> FOF_NORECURSEREPARSETreat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
    > >> FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
    > >> FOF_SILENT Do not display a progress dialog box.
    > >> FOF_SIMPLEPROGRESS Display a progress dialog box but do not show the file names.
    > >> FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
    > >> FOF_WANTNUKEWARNINGVersion 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
    > >>
    > >>
    > >>
    > >>
    > >>
    > >> --
    > >> --------------------------------------------------------------------------------------------------
    > >> http://webdiary.smh.com.au/archives/_comment/001075.html
    > >> =================================================
    > >> "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:603740A2-288A-4FE5-BCD4-FD1AC82C6298@microsoft.com...
    > >> > Is there any way to create a zipped folder from the command line? "Compact"
    > >> > doesn't really do what I want (just uses drivespace or something to compress
    > >> > the folder).
    > >> >
    > >> > What I'm trying to do is make a simple batch file that creates a folder,
    > >> > throws a bunch of files with the same extenstion into it, and then zips it
    > >> > up- but without a command line version of the built-in windows zip program
    > >> > this will be impossible (through batch file anyway). Any ideas?
    > >>
    >
  9. Archived from groups: microsoft.public.windowsxp.general (More info?)

    You have to create the folders/zips first. It's only sample code I did not do a full blown application as people want to incorporate the code within their own bigger scripts.

    This creates a empty zip file. IE it writes to a file. Find your own empty zip and type in Start Run
    edit /70 "c:\yourzip.zip"

    Using binary view (the /70) means edit shows the character code in the status bar.

    PK<a club (code 5)><a spade (code 6)> followed by 18 nulls (Code 0)

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.OpenTextFile("c:\Test.zip", 8, vbtrue)
    BlankZip = "PK" & Chr(5) & Chr(6)
    For x = 0 to 17
    BlankZip = BlankZip & Chr(0)
    Next
    ts.Write BlankZip

    --
    --------------------------------------------------------------------------------------------------
    http://webdiary.smh.com.au/archives/_comment/001075.html
    =================================================
    "Fred" <Fred@discussions.microsoft.com> wrote in message news:58B3D7CD-6406-4754-A264-9D865E6816D4@microsoft.com...
    >I can't get the script to work either.
    >
    > Here is my session copied from a DOS Window:
    >
    > ---
    > D:\Vbs> type ZipTest.vbs
    > Set objShell = CreateObject("Shell.Application")
    > Set Ag=Wscript.Arguments
    > set WshShell = WScript.CreateObject("WScript.Shell")
    >
    > Set DestFldr=objShell.NameSpace(Ag(1))
    > Set SrcFldr=objShell.NameSpace(Ag(0))
    > Set FldrItems=SrcFldr.Items
    > DestFldr.CopyHere FldrItems, &H214
    > Msgbox "Finished"
    >
    > D:\Vbs> dir c:\test
    > Volume in drive C has no label.
    > Volume Serial Number is A0FD-483A
    >
    > Directory of c:\test
    >
    > 06/21/2005 17:06 <DIR> .
    > 06/21/2005 17:06 <DIR> ..
    > 06/21/2005 13:44 1,671,168 Track01 (2) .ISO
    > 06/21/2005 13:43 1,671,168 Track01.ISO
    > 06/21/2005 13:45 1,671,168 Track01.zip
    > 3 File(s) 5,013,504 bytes
    > 2 Dir(s) 125,554,696,192 bytes free
    >
    > D:\Vbs> cscript ZipTest.vbs c:\test c:\test\test.zip
    > Microsoft (R) Windows Script Host Version 5.6
    > Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
    >
    > D:\Vbs\ZipTest.vbs(8, 1) Microsoft VBScript runtime error:
    > Object required: 'DestFldr'
    >
    > D:\Vbs>
    > ---
    >
    > My intentions are to copy the files in c:\test to the zip file
    > c:\test\test.zip.
    >
    > Any ideas?? TIA
    >
    >
    > "David Candy" wrote:
    >
    >> You cut and pasted it wrong.
    >>
    >> I've been playing with it and when zipping it often doesn't do anything. Poping up a dialog box makes it work. It could be a timing issue. But putting a msgbox at the end of the code always zips.
    >>
    >> unzip <folder or zip name to be copied from> <folder or zip name to copy to>
    >> unZip.vbs" "C:\Documents and Settings\David Candy\Desktop\test" "C:\Documents and
    >> Settings\David Candy\Desktop\AFDG_W.zip"
    >>
    >>
    >> Set objShell = CreateObject("Shell.Application")
    >> Set Ag=Wscript.Arguments
    >> set WshShell = WScript.CreateObject("WScript.Shell")
    >>
    >> Set DestFldr=objShell.NameSpace(Ag(1))
    >> Set SrcFldr=objShell.NameSpace(Ag(0))
    >> Set FldrItems=SrcFldr.Items
    >> DestFldr.CopyHere FldrItems, &H214
    >> Msgbox "Finished"
    >>
    >>
    >>
    >> --
    >> --------------------------------------------------------------------------------------------------
    >> http://webdiary.smh.com.au/archives/_comment/001075.html
    >> =================================================
    >> "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:709EDEB0-9BD7-48BF-8399-40E6AB1A74AF@microsoft.com...
    >> > David,
    >> >
    >> > I tried that script and ran into a few problems. I wanted to first try it in
    >> > its original format, so I copied and pasted the top portion. I have some
    >> > programming experience but skipped the whole shell scripting phase, so I just
    >> > assumed that you needed the private constants and the top part of the
    >> > program, minus the parts that are obviously not code.
    >> >
    >> > The command line didn't like the constants, so I figured those might be
    >> > built in, and then it accepted most of the script except for the last part-
    >> > "DestFldr.CopyHere FldrItems, &H214" gave me the error:
    >> >
    >> > & H214 ' DestFldr.CopyHere' is not recognized as an internal or external
    >> > command, operable program or batch file. 'H214' is not recognized as an
    >> > internal or external command, operable program or batch file.
    >> >
    >> > Any ideas?
    >> >
    >> > Thanks,
    >> > Mike
    >> >
    >> >
    >> > "David Candy" wrote:
    >> >
    >> >> This script extracts files from a zip passed on the command line and makes a folder on the desktop with the contents. Just do reverse to zip. A new zip file is easly created (look at a new one - it's 14 bytes of mostly null but starting PK). This uses Shell commands rather than File commands. We are working with shell objects that merely happen to be files.
    >> >>
    >> >> Set objShell = CreateObject("Shell.Application")
    >> >> Set Ag=Wscript.Arguments
    >> >> set WshShell = WScript.CreateObject("WScript.Shell")
    >> >>
    >> >>
    >> >> Set DestFldr=objShell.NameSpace(Ag(1))
    >> >> Set SrcFldr=objShell.NameSpace(Ag(0))
    >> >> Set FldrItems=SrcFldr.Items
    >> >> DestFldr.CopyHere FldrItems, &H214
    >> >>
    >> >>
    >> >> I specified options of 0x214 (&h214) in hex. 200 + 10 + 4, change to suit your purposes.
    >> >>
    >> >> Private Const FO_MOVE As Long = &H1
    >> >> Private Const FO_COPY As Long = &H2
    >> >> Private Const FO_DELETE As Long = &H3
    >> >> Private Const FO_RENAME As Long = &H4
    >> >>
    >> >> Private Const FOF_MULTIDESTFILES As Long = &H1
    >> >> Private Const FOF_CONFIRMMOUSE As Long = &H2
    >> >> Private Const FOF_SILENT As Long = &H4
    >> >> Private Const FOF_RENAMEONCOLLISION As Long = &H8
    >> >> Private Const FOF_NOCONFIRMATION As Long = &H10
    >> >> Private Const FOF_WANTMAPPINGHANDLE As Long = &H20
    >> >> Private Const FOF_CREATEPROGRESSDLG As Long = &H0
    >> >> Private Const FOF_ALLOWUNDO As Long = &H40
    >> >> Private Const FOF_FILESONLY As Long = &H80
    >> >> Private Const FOF_SIMPLEPROGRESS As Long = &H100
    >> >> Private Const FOF_NOCONFIRMMKDIR As Long = &H200
    >> >>
    >> >> FlagDescription
    >> >> FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and file names, this flag is ignored.
    >> >> FOF_CONFIRMMOUSENot currently used.
    >> >> FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
    >> >> FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
    >> >> FOF_NOCONFIRMATION Respond with "Yes to All" for any dialog box that is displayed.
    >> >> FOF_NOCONFIRMMKDIR Do not confirm the creation of a new directory if the operation requires one to be created.
    >> >> FOF_NO_CONNECTED_ELEMENTSVersion 5.0. Do not move connected files as a group. Only move the specified files.
    >> >> FOF_NOCOPYSECURITYATTRIBSVersion 4.71. Do not copy the security attributes of the file.
    >> >> FOF_NOERRORUI Do not display a user interface if an error occurs.
    >> >> FOF_NORECURSIONOnly operate in the local directory. Don't operate recursively into subdirectories.
    >> >> FOF_RECURSEREPARSERecurse into reparse points. The default is to not recurse.
    >> >> FOF_NORECURSEREPARSETreat reparse points as objects, not containers. You must set _WIN32_WINNT to 5.01 or later to use this flag. See Shell and Common Controls Versions for further discussion of versioning.
    >> >> FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
    >> >> FOF_SILENT Do not display a progress dialog box.
    >> >> FOF_SIMPLEPROGRESS Display a progress dialog box but do not show the file names.
    >> >> FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified and any files were renamed, assign a name mapping object containing their old and new names to the hNameMappings member.
    >> >> FOF_WANTNUKEWARNINGVersion 5.0. Send a warning if a file is being destroyed during a delete operation rather than recycled. This flag partially overrides FOF_NOCONFIRMATION.
    >> >>
    >> >>
    >> >>
    >> >>
    >> >>
    >> >> --
    >> >> --------------------------------------------------------------------------------------------------
    >> >> http://webdiary.smh.com.au/archives/_comment/001075.html
    >> >> =================================================
    >> >> "Tempest261" <Tempest261@discussions.microsoft.com> wrote in message news:603740A2-288A-4FE5-BCD4-FD1AC82C6298@microsoft.com...
    >> >> > Is there any way to create a zipped folder from the command line? "Compact"
    >> >> > doesn't really do what I want (just uses drivespace or something to compress
    >> >> > the folder).
    >> >> >
    >> >> > What I'm trying to do is make a simple batch file that creates a folder,
    >> >> > throws a bunch of files with the same extenstion into it, and then zips it
    >> >> > up- but without a command line version of the built-in windows zip program
    >> >> > this will be impossible (through batch file anyway). Any ideas?
    >> >>
    >>
Ask a new question

Read More

Microsoft Command Line Windows XP