Link to home
Start Free TrialLog in
Avatar of cutecupid
cutecupid

asked on

Zip a folder, files and Subfolder

uSING vbscript, i need to zip files and sub folder of a folder.
Note: I am having Winzip in my local desktop
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There are a number of examples on this page for zipping folders using VBScript.

The second script looks the most comprehensive as it handles empty sub folders

http://www.robvanderwoude.com/vbstech_files_zip.php
Avatar of cutecupid
cutecupid

ASKER

---------------------------
Windows Script Host
---------------------------
Script:      D:\New_project\zippingafolder.vbs
Line:      9
Char:      1
Error:      File not found
Code:      800A0035
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------
?

We will need a sample of the code you ran in order to work out what is wrong.

Quite simply from that error it is suggesting that it could not find the file, besides that there is not much more we can tell.  I would presume the path to the file is incorrect in the code you ran.
strDate = Year(Date) & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2) & Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2)

strFolderToZip = "D:\New_project\test"
strZipFileToCreate = "D:\New_project\test\Scripts_" & strDate & ".zip"
strWinzip = "C:\Program Files\WinZip\Winzip32.exe"

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strWinZip = objFSO.GetFile(strWinZip).ShortPath
strCommand = strWinzip & " -min -a -r """ & strZipFileToCreate & """ """ & strFolderToZip & """"
objShell.Run strCommand, 1, True

MsgBox "Done"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
[Window Title]
C:\Program

[Content]
Windows cannot find 'C:\Program'. Make sure you typed the name correctly, and then try again.

[OK]
Unsual if you can not see the C: Program folder, but that could be down to a different language installation e.g. the word program is sometimes written in the local insallation language.   I presume that you are also using windows.

To get round all of this and as long as you you have Winzip installed on your PC, browse to the location of the Winzip32.exe file where ever it is installed on the PC (do a search if you can't find it) and copy the path of it into the script.
thanks your effort, it worked well for me..

thanks a lot ...
Really good guidance