Windows default zip file extract

Zip and unzip files

Zipped (compressed) files take up less storage space and can be transferred to other computers more quickly than uncompressed files. In Windows, you work with zipped files and folders in the same way that you work with uncompressed files and folders. Combine several files into a single zipped folder to more easily share a group of files.

Locate the file or folder that you want to zip.

Press and hold (or right-click) the file or folder, select (or point to) Send to, and then select Compressed (zipped) folder.

A new zipped folder with the same name is created in the same location. To rename it, press and hold (or right-click) the folder, select Rename, and then type the new name.

Locate the zipped folder that you want to unzip (extract) files or folders from.

Do one of the following:

To unzip a single file or folder, open the zipped folder, then drag the file or folder from the zipped folder to a new location.

To unzip all the contents of the zipped folder, press and hold (or right-click) the folder, select Extract All, and then follow the instructions.

To add files or folders to a zipped folder you created earlier, drag them to the zipped folder.

If you add encrypted files to a zipped folder, they’ll be unencrypted when they’re unzipped, which might result in unintentional disclosure of personal or sensitive information. For that reason, we recommend that you avoid zipping encrypted files.

Some types of files, like JPEG images, are already highly compressed. If you zip several JPEG pictures into a folder, the total size of the folder will be about the same as the original collection of pictures.

How to restore Windows default Zip file functionality?

I recently lost the default file association for Zip files in Windows Vista (I think it happened when I uninstalled WinAce, but I can’t be completely sure). How can I restore this association back to the Windows default?

7 Answers 7

Try this article from MSDN: How to restore the native Zip file integration in Windows. You only have to do this from an elevated (run as administrator) command prompt:

The first post is the long way to perform this three step process. Here is a simple and easy way to change the file association back to Windows Explorer:

Locate the file

Right click the file

Locate the «open with» button and click it

Browse to the windows explorer to «c:\windows\explorer» and highlight the explorer file

Check use as default-apply-ok

This works for me in Windows 7:

cmd /c assoc .zip=CompressedFolder

I had the same problem and this worked for me:

  • Click the Windows Orb (Start) > All Programs > Accessories and right-click Command Prompt, then «Run as Administrator».
  • Type assoc .zip=CompressedFolder and press Enter.
  • You may have to restart the computer.

The best way is to try using the Open With. context menu to set Explorer to be the default file handler.

However, if that does not work you can try the following to force Explorer to handle ZIP file. (Source for this info)

Читайте также:  Windows that lift up

Make a .reg file with the following:

Then, in an admin command prompt type:

One other suggestion I have seen is to simply go into the Default Programs editor in Control Panel and removing the association you currently have. However, this was for XP and I’m not sure that it will work for Vista. However, you may want to try this before playing around the registry.

Or, you could just install 7-zip which is free and much more powerful.

The quickest way is to get any .zip file and right click on it, go down to «Open with» and choose «Choose Default Program» or «other» then on this box, you should see «Windows Explorer» or whatever you used to use listed.

Click the button «Always use the selected program to open this kind of file» at the bottom and then double click on the program you want to use.

This should then open up ZIP files in a new default program.

If this method does not work, I can give you the manual instructions for reassigning .zip with Explorer, but this is by far the quickest.

7-zip & Windows 7: Make “Extract to ” default on double-click

I’m trying to find a way to make the action you can perform from the context menu, «Extract to » the default action when double-clicking the file instead of simply launching 7-zip. Is there a simple way to do this?

In the alternative, I gather I could try passing parameters into the following:

But I’m not sure how to set this up (how to pass the filename parameter, and can I do this directly or will I have to write a batch file instead and pass the filename to it? The latter I find irritatingly unelegant, but whatever works.

6 Answers 6

Unfortunately, afrazier’s batch program method won’t work; Windows doesn’t handle opening multiple files like that. When you try to open multiple files with a program, Windows doesn’t open a single instance of the program and pass the files as multiple arguments to that one instance. Instead, Windows opens many instances of the program (as many instances as there are files), passing one file to each instance. It would be nice if you could just use %* and pass a bunch of files to a single .bat, and have that .bat run a loop processing each file one at a time, but unfortunately you can only use %1 when setting these kinds of actions in the registry.

Someone with some time on their hands could write a program that uses a mutex object to check if there is another instance already running, and if there is, to pass it’s file to that instance and then close, whereon the original instance will put that file in a queue and get to it once it’s done processing its own file. a batch could do the trick using tasklist and find , too, but that’s not as good of a solution as mutex.

Anyway, try this for your extract command registry value to get the right folder name:

This will create a new folder in the same directory as the source archive with the same name as the source archive (sans the file extension).

Also, I added the -aou switch to automatically avoid filename conflicts (7z will append a number to the end of a file instead prompting you whether you want to overwrite or whatever).

How can you zip or unzip from the script using ONLY Windows’ built-in capabilities?

In Windows you can zip some files by

right click → Send toCompressed (zipped) folder

And unzip by double clicking on the .zip file and extract the files.

Is there a way to apply those abilities from a script (.bat file) without the need to install any third-party software?

Читайте также:  Все для dsl linux

17 Answers 17

Back in 2013, that was not possible. Microsoft didn’t provide any executable for this.

From Windows 8 on, .NET Framework 4.5 is installed by default, with System.IO.Compression.ZipArchive and PowerShell available, one can write scripts to achieve this, see https://stackoverflow.com/a/26843122/71312

To expand upon Steven Penny’s PowerShell solution, you can incorporate it into a batch file by calling powershell.exe like this:

As Ivan Shilo said, this won’t work with PowerShell 2, it requires PowerShell 3 or greater and .NET Framework 4.

If you have Java installed, you can compress to a ZIP archive using the jar command:

c = Creates a new archive file.

M = Specifies that a manifest file should not be added to the archive.

f = Indicates target file name.

PowerShell 5.0

Create result.zip from the entire Test folder:

Extract the content of result.zip in the specified Test folder:

It isn’t exactly a ZIP, but the only way to compress a file using Windows tools is:

Advanced example (from ss64.com):

Using 7-Zip:

Zip: you have a folder foo , and want to zip it to myzip.zip

Unzip: you want to unzip it ( myzip.zip ) to current directory ( ./ )

100 machines in production which don’t have 7zip on them. To install that I would have to get the DevOps install it on all those machines and on all new machines that will be added to the clusters. I would rather avoid it. – Roee Gavirel May 9 ’16 at 5:27

I’ve been looking to answer this exact question and from my research, DiryBoy’s response seems to be accurate.

I found the compact.exe program compresses files but not to create a highly compressed file (or set of files). It is similar to the option you get when right clicking on a drive letter or partition in Windows. You get the option to do cleanup (remove temp files, etc) as well as compress files. The compressed files are still accessible but are just compressed to create space on a drive that is low on space.

I also found compress.exe which I did happen to have on my computer. It isn’t natively on most windows machines and is part of the 2003 resource kit. It does make a zipped file of sorts but it is really more similar to files from a windows setup disk (has the underscore as the last character of the file extension or name). And the extract.exe command extracts those files.

However, the mantra is, if it can be done natively via the GUI then there is likely a way to do it via batch, .vbs, or some other type of script within the command line. Since windows has had the ‘send to’ option to create a zip file, I knew there had to be a way to do it via command line and I found some options.

Here is a great link that shows how to zip a file using windows native commands.

I tested it with a directory containing multiple nested files and folders and it worked perfectly. Just follow the format of the command line.

There is also a way to unzip the files via command line which I found as well. One way, just brings open an explorer window showing what the content of the zipped file is. Some of these also use Java which isn’t necessarily native to windows but is so common that it nearly seems so.

Практическое руководство. Сжатие и извлечение файлов How to: Compress and extract files

Пространство имен System.IO.Compression предоставляет следующие типы для сжатия и распаковки файлов и потоков. The System.IO.Compression namespace contains the following types for compressing and decompressing files and streams. Вы также можете использовать эти типы для чтения и изменения содержимого сжатого файла. You can also use these types to read and modify the contents of a compressed file.

Читайте также:  Epson r200 drivers windows

В примерах ниже показано несколько операций для работы со сжатыми файлами. The following examples show some of the operations you can perform with compressed files. Для этих примеров требуется добавить в проект следующие пакеты NuGet: These examples require the following NuGet packages to be added to your project:

Если вы используете .NET Framework, добавьте в проект ссылки на эти две библиотеки: If you’re using .NET Framework, add references to these two libraries to your project:

Пример 1: Создание и извлечение ZIP-файла Example 1: Create and extract a .zip file

В следующем примере показано, как создавать и извлекать сжатый файл .zip с помощью класса ZipFile. The following example shows how to create and extract a compressed .zip file by using the ZipFile class. Он сжимает содержимое папки в новый ZIP-файл и затем извлекает его в новую папку. The example compresses the contents of a folder into a new .zip file, and then extracts the zip to a new folder.

Чтобы запустить пример, создайте папку start в папке программы и заполните ее файлами для сжатия. To run the sample, create a start folder in your program folder and populate it with files to zip.

Пример 2: Извлечение файлов с определенными расширениями Example 2: Extract specific file extensions

В этом примере выполняется итерация по содержимому существующего ZIP-файла и извлекаются файлы с расширением .txt. The next example iterates through the contents of an existing .zip file and extracts files that have a .txt extension. Здесь используется класс ZipArchive для доступа к ZIP-файлу и класс ZipArchiveEntry для проверки отдельных элементов. It uses the ZipArchive class to access the zip, and the ZipArchiveEntry class to inspect the individual entries. Метод расширения ExtractToFile для объекта ZipArchiveEntry доступен в классе System.IO.Compression.ZipFileExtensions. The extension method ExtractToFile for the ZipArchiveEntry object is available in the System.IO.Compression.ZipFileExtensions class.

Чтобы запустить пример, поместите ZIP-файл с именем result.zip в папку программы. To run the sample, place a .zip file called result.zip in your program folder. По запросу укажите имя папки для извлечения. When prompted, provide a folder name to extract to.

При распаковке файлов важно убедиться в отсутствии вредоносных путей, которые могут вести за пределы каталога, в который вы извлекаете файлы. When unzipping files, you must look for malicious file paths, which can escape out of the directory you unzip into. Такая атака известна как обход путей. This is known as a path traversal attack. В следующем примере показано, как правильно проверить наличие вредоносных путей и безопасно извлечь файлы. The following example demonstrates how to check for malicious file paths and provides a safe way to unzip.

Пример 3. Добавление файла в существующий ZIP-файл Example 3: Add a file to an existing zip

В следующем примере используется класс ZipArchive для доступа к существующему ZIP-файлу и добавления в него файла. The following example uses the ZipArchive class to access an existing .zip file, and adds a file to it. Новый файл сжимается при добавлении в существующий ZIP-файл. The new file gets compressed when you add it to the existing zip.

Пример 4. Сжатие и распаковка GZ-файлов Example 4: Compress and decompress .gz files

Также вы можете использовать классы GZipStream и DeflateStream для сжатия и распаковки данных. You can also use the GZipStream and DeflateStream classes to compress and decompress data. Они применяют тот же алгоритм сжатия. They use the same compression algorithm. Вы можете распаковать объекты GZipStream, которые записаны в GZ-файл, с помощью многих распространенных средств. You can decompress GZipStream objects that are written to a .gz file by using many common tools. В следующем примере показано, как использовать класс GZipStream для сжатия и распаковки каталога файлов. The following example shows how to compress and decompress a directory of files by using the GZipStream class:

Оцените статью