How to run 7Zip via Batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
YetAnotherUser
Posts: 1
Joined: 01 Sep 2020 04:16

How to run 7Zip via Batch

#1 Post by YetAnotherUser » 01 Sep 2020 04:26

Dear all,

I'm working on a small .bat program which should do some small tasks in my testenvironment
One piece should be to zip all logfiles in a specific folder, using the 7Zip application

When I open a command box, walk through the folder (c:\program files\7-zip) and run the following command: 7z.exe a -tzip c:\temp\mylogs.zip c:\testenvironment\logs\*.log everything works absolutely perfect.

When I run my batch which includes this start "" "c:\program files\7-zip\7z.exe a -tzip c:\temp\mylogs.zip c:\testenvironment\logs\*.log" windows come up with an error saying windows cannot find c:\program files\7-zip\7z.exe a -tzip c:\temp\mylogs.zip c:\testenvironment\logs\*.log

Any ideas on how to resolve this ?
Thanks in advance

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: How to run 7Zip via Batch

#2 Post by Squashman » 01 Sep 2020 06:30

by putting quotes around the entire execution of 7zip, you are basically telling the command processor to look for an executable file named the same as everything inside the quotes. Quotes are only needed for the file paths.

Post Reply