

- #HOW TO SET ZIP FOLDER WINDOWS 10 ZIP FILE#
- #HOW TO SET ZIP FOLDER WINDOWS 10 CODE#
- #HOW TO SET ZIP FOLDER WINDOWS 10 WINDOWS 7#
' this is needed because CopyHere() returns immediately after starting an asynchronous copy process ' wait until the file appears in the ZIP file, ' folder is empty, skip it as empty folders can't be compressed
#HOW TO SET ZIP FOLDER WINDOWS 10 ZIP FILE#
' ZIP file is included in Items collection and is recognized as folder, thus skip it to avoid script errors Set targetFolderObj = app.NameSpace(target) Set sourceFolderObj = app.NameSpace(source) Set app = CreateObject("Shell.Application") ' write ZIP header, this ensures that Windows recognizes the file as "ZIP Folder" Set zip = fso.OpenTextFile(target, 2, vbtrue) Set fso = CreateObject("Scripting.FileSystemObject") ' remove trailing slashes as we add slashes when needed later It's a timing issue as the newly created ZIP file is included in the Items collection when the script is executed on fast machines. Here is an updated version which fixes the "Object required" error reported by pihentagy. My wait loop is based on an answer to a similar issue posted here. One of these issues is that the method returns immediately while the copy process starts in background whereas multiple CopyHere() calls will interfere each other and the ZIP won't be created correctly. Using the CopyHere() method in VBS introduces several issues. I will post something related to WSkids answer as sadly i cannot use the comment function. ' delay until at least items at the top level are availableĭo Until objApp.NameSpace( target ).Items.Count + intSkipped = intSrcItems IntSrcItems = objApp.NameSpace( source ).Items.Count ObjApp.NameSpace( target ).CopyHere objItem ' if this folder is empty, then skip it as it can't compress empty folders Set objFolder = objFSO.GetFolder( objItem.Path ) ' Loop over items within folder and use CopyHere to put them into the zip folderįor Each objItem in objApp.NameSpace( source ).Items Set objApp = CreateObject( "Shell.Application" ) Here, you can individually select the file types that you want to open with 7zip File Manager by default. Then, scroll down on the right panel and click on Set defaults by file type. On the left panel, click on Default apps. Press Win+I to open Settings, and click on Apps. Zip.Write "PK" & Chr(5) & Chr(6) & String( 18, Chr(0) ) Method 3 Set 7zip as default unzipper from Settings. ' this is the header to designate a file as a zip To select multiple files at once, hold the Ctrl key as you click each. Select all files you want to add to the zip. Set zip = objFSO.OpenTextFile(target, 2, vbtrue) Navigate to the folder that contains files you want to zip. Set objFSO = CreateObject("Scripting.FileSystemObject")
#HOW TO SET ZIP FOLDER WINDOWS 10 CODE#
Here is the vbs code - Set Args = Wscript.Arguments It won't copy empty folders so be careful. Path to script, source folder, zip file to make (include. Usage: in the run box or command line put- "C:\zipper.vbs" "C:\folderToZip\" "C:\mynewzip.zip"
#HOW TO SET ZIP FOLDER WINDOWS 10 WINDOWS 7#
The script was originally made for Windows XP, but it also works in Windows 7 圆4 Ultimate - no guarantee's if Windows will keep around the various Shell objects this uses. Copy and paste the script into a file with the extension ".vbs". I can see that this could be a potential problem, however at the moment this is working fine again as far as I can see - if I have the issue again I guess I'll have to check out the file structure, maybe that could be the issue.I've combined this script from several different sources to suit my needs better. Why not check out our User Provisioning Tool on our web site These broken directories with exceptionally deep paths that you can't I use the following tried and tested RoboCopy method for removing There is an exceptionally deep directory structure in the folder youĪre zipping, the compression may fail but show no error. Seems that when you click "Send to compressed (zipped) folder" if Looking further into this I found that it worked most folders just notĪfter a while I realised that I had a Visual Studio project sourceĬode in this folder that had that annoying deep object folder problem and it I've recently had a problem when using the "Send toĬompressed (zipped) folder" context menu item nothing happens on I've copied the comments from this link mentioned earlier - When using the "Send to compressed (zipped) folder" context menu item nothing happens
