Use 7-zip to zip a file with a batch file

7-Zip will work in conjunction with a batch file, on Windows, to zip a file automatically. Install the program and copy 7z.exe to the system32 directory. The syntax is this:


7z a myfile.zip myfile


That’s it, kids. Note: I don’t really understand how 7-zip is different than other zip utilities, but, the archive which it creates must be extracted by the same program. Other programs will say that the archive is corrupt.

@ECHO OFF
cd "C:\Documents and Settings\All Users\Application Data\
MYSQL\MySQL Server 5.5\data"
7z a myfile.zip myfile
move myfile.zip "C:\Inetpub\wwwroot\getit\myfile.zip"
cd "C:\Inetpub\wwwroot\getit"
ping 1.1.1.1 -n 1 -w 600000>NUL
del myfile.zip

exit 

I use something like this to create an archive which I can then download at my house via “wget” and a Linux cron job. Bada-boom, bada-bing.

Leave a Reply