Zip in Windows 10 Pro batch file
The Windows 10 Pro command prompt does not have a command to compress zip.
However, PowerShell has a Compress-Archive command, so you can call PowerShell’s ps1 file from a batch file to compress it.
The file layout configuration is as follows.
The folder to be compressed is assumed to be the same as the one under the folder.
|Folder you want to compress||Compressed Folder Name|
@echo off powershell -ExecutionPolicy Unrestricted .\a.ps1 exit /b
Compress-Archive -Path C:\temp\common\ -DestinationPath C:\temp\common.zip
Execute this file.
I was able to run the batch file and zip it.
Use the powershell command
Zip the file using the powershell command in a batch file without creating a ps1 file.
@echo off powershell compress-archive common common.zip
Execute zip command via wsl
If you have a Linux environment with wsl, you can use the zip command via the wsl command.
Install the zip command via wsl sudo apt install zip.
Compress the file under c:\tmp\ to a.zip.
c:\tmp>wsl zip a -r9 .