TechGuy
TechGuy

Reputation: 4560

Unable to zip using 7z in batch file

Here i'm using batch file to take backups & then zip those backups.Backup process successfully.But zipping process failed and it always show to install the 7zip.But i already installed 7ip.

Here goes my code

@ECHO OFF
osql -S .\sqlexpress -E -i "C:\Sql_Backup.sql" -o "E:\test\testbk.sql"
ECHO.
7za a -tzip "E:\test\newfile.zip" "E:\test\newfile.Bak"
ECHO.
del "E:\test\newfile.Bak"
exit

Upvotes: 2

Views: 1210

Answers (2)

Sunny
Sunny

Reputation: 8292

May be system couldn't find where your 7z.exe is, so just tell your system where your compressing program is by giving the correct path like below:

C:\Program Files\7-Zip\7z.exe a -tzip "E:\test\newfile.zip" "E:\test\newfile.Bak"

Upvotes: 1

James L.
James L.

Reputation: 9453

What does "it always show to install 7zip" mean? Are you seeing an actual error message? Is the error message this?

'7za' is not recognized as an internal or external command,
operable program or batch file.

If so, that's because the program is 7z, not 7za. Just change it in your batch file and see if it starts working...

Upvotes: 2

Related Questions