Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

7-zip using vbs

Status
Not open for further replies.

causative

Technical User
Mar 6, 2009
12
PL
Hi
I have a question is it a good option to compress folders to separate archives using 7-zip in vbs?
It's easy to do it in bat:

Code:
FOR /D %%F IN ("*") DO (
"C:\Program Files (x86)\7-Zip\7z.exe" a -t7z -mx9 -r -y "%%F.7z" "%%F"
)

I was searching for something in vbs, but codes are very long and quite difficult to understand.
If it's ok doing it in vbs can somebody give me some example ( simple code ) or longer with comments?
 
Why would you write a VBS script when a .BAT does the job ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi
First of all I would like to learn this.

Second - I have few other scripts in vbs and I could include it on it to be my work more automated
 
Have a look at the WshShell.Run method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
There are many samples of such a scripts, but I wonder is it a good solution and fast solution to do it in WshShell.Run method.
I read that is not, but meaby somebody uses it on a daily and know something more....
This seems to be quite complicated.
 
Not complicated at all, though I admit escaping the install path is tricky. Something like this should get you started.

Code:
Set objShell = wscript.createObject("wscript.shell")
InstallPath = """C:\Program Files (x86)\7-Zip\7z.exe"""
vTarget = "c:\myfolder\Test.7z"
vSource = "c:\myfolder\foldertozip\*.*"

objShell.Run InstallPath & " a -t7z -mx9 -r -y " & vTarget & " " & vSource

And if you want to do this for all subfolders in a folder, use the FileSystem Object, specifically the GetFolders method and Subfolders collection:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top