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
VB Script

Avatar of undefined
Last Comment
cutecupid

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
RobSampson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
wobbled

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
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  
---------------------------
wobbled

?

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
cutecupid

ASKER
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
wobbled

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
cutecupid

ASKER
[Window Title]
C:\Program

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

[OK]
wobbled

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
cutecupid

ASKER
thanks your effort, it worked well for me..

thanks a lot ...
cutecupid

ASKER
Really good guidance