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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ZIP a file

Status
Not open for further replies.

giginge

Technical User
Jul 9, 2003
13
0
0
IT
Is there a program in vbscript to zip a file?
Or How can I do to Zip a file using vbscript?
Thanks.
 
You can use the Run method of the WshShell object to execute a command line utility like pkzip.

Hope This Help
PH.
 
Here is one I use.
Enjoy Bob

returncode=msgbox ("mount a 3.5 diskette for backup",65,"backup start")
if returncode=1 then
Set ss = CreateObject("WScript.Shell")
ss.run "COMMAND /C C:\util\pkzip.exe a:master77.zip y:\rds\rds77\master.txt ",1,TRUE
set ss = nothing
msgbox "backup is done please remove the diskette",64,"backup finished"
end if
 
I am trying to write some code that will zip up log files and then FTP them to another server any ideas ?

Thanks
 
I found WinZip's command line extension quite useful (then you're not limited to 8 char names):

Dim myObjFSO
Set myObjFSO = CreateObject("scripting.filesystemobject")
CheckFolder "C:\source"

Sub CheckFolder(strPath)
Dim objFolder
Dim objFile
Dim objSubdirs
Dim objLoopFolder

Set objFolder = myObjFSO.GetFolder(strPath)

'Do what you need to do below

For Each objFile In objFolder.Files
If UCase(Right(objFile.Name, 4)) = ".LOG" Then
Set MyObj=CreateObject("WScript.Shell")
Msgbox "C:\source\WZZIP.EXE test.zip " & strPath &"\"& objFile.Name
MyObj.Run "C:\source\WZZIP.EXE test.zip " & strPath &"\"& objFile.Name

End If
Next


'Loop through all subdirectories and do the same thing (if required).

Set objSubdirs = objFolder.SubFolders
For Each objLoopFolder In objSubdirs
CheckFolder objLoopFolder.Path
Next

Set objSubdirs = Nothing
Set objFolder = Nothing

End Sub


MsgBox "Processed files.", vbSystemModal, "Batch zipper"

You can download the extension from:


As to the FTPing - can't help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top