VJ
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 11/17/2011
-
Status: offline
|
VB Script to zip the file.
Friday, November 25, 2011 7:20 PM
( permalink)
Hi, Below VB Script moves file from sDirectoryPath to sRootPath. ------------------------------------------------ if archiveMode="Y" then If oFSO.FileExists(sRootPath & oFile.Name) Then set oDupFileFound = oFSO.getFile(sRootPath & oFile.Name) oDupFileFound.Delete(True) oFSO.MoveFile sDirectoryPath & "\" & oFile.Name , sRootPath else oFSO.MoveFile sDirectoryPath &"\" & oFile.Name , sRootPath '<---- i want to replace this with zip code end if end if ------------------------------------------------ Instead of just moving file i would like to zip all the files in SRootPath as single zip file. Please suggest...!!
|
|
|
|
Hackoo
-
Total Posts
:
105
- Scores: 4
-
Reward points
:
0
- Joined: 6/25/2010
-
Status: offline
|
Re:VB Script to zip the file.
Sunday, November 27, 2011 4:57 AM
( permalink)
Hi ! Take a look at this Link
|
|
|
|
longbow22
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 12/19/2011
-
Status: offline
|
Re:VB Script to zip the file.
Wednesday, December 21, 2011 1:25 AM
( permalink)
Sorry[/style] [/style]to[/style] piggy[/style] back[/style] off[/style] this[/style] post[/style], but[/style] every[/style] [/style]time[/style] I[/style] try[/style] [/style]to[/style] add[/style] a[/style] [/style]new[/style] post[/style] it[/style] comes[/style] up[/style] [/style]with[/style] a[/style] blank[/style] box.[/style] This[/style] [/style]Is[/style] my[/style] first[/style] post[/style] [/style]And[/style] first[/style] attempt[/style] at[/style] vbs.[/style] [/style] Anyway[/style] I[/style] am[/style] trying[/style] [/style]to[/style] unzip[/style] a[/style] file[/style] but[/style] keep[/style] getting[/style] the[/style] [/style]error[/style]: Object[/style] Required[/style] objShell.Namespace[/style] [/style]On[/style] this[/style] line.[/style] objShell.NameSpace[/style](strFolderName[/style]).CopyHere[/style] objShell.NameSpace[/style](strFileName[/style]).Items[/style] Function[/style] Unzip[/style](strFileName[/style],strFolderName[/style])[/style] Dim[/style] ParentFolder[/style] Dim[/style] objShell[/style] Dim[/style] objFSO[/style] Dim[/style] objFolder[/style] ' For this to work we need to zip the CONTENTS of C:\Rent Roll not including the main folder name C:\Rent Roll[/style] ParentFolder[/style] = [/style]"C:\"[/style] [/style] ' Create Shell.Application so we can use the CopyHere method[/style] Set[/style] objShell[/style] = [/style]CreateObject[/style]([/style]"Shell.Application"[/style])[/style] ' Create FileSystemObject so we can use FolderExists and CreateFolder if necessary[/style] Set[/style] objFSO[/style] = [/style]CreateObject[/style]([/style]"Scripting.FileSystemObject"[/style])[/style] [/style] ' Create folder to receive files if it doesn' t already exist[/style] If[/style] objFSO.FolderExists[/style](strFolderName[/style]) [/style]Then[/style] Wscript.Echo[/style] [/style]"Folder exists."[/style] [/style]'BackupFiles strThumbDrive,strFromDir,strToDir[/style] [/style]Set[/style] objFolder[/style] = objShell.NameSpace[/style](ParentFolder[/style]) [/style] [/style]Set[/style] objFolder[/style] = objFSO.GetFolder[/style](strFolderName[/style])[/style] objShell.NameSpace[/style](strFolderName[/style]).CopyHere[/style] objShell.NameSpace[/style](strFileName[/style]).Items[/style] Wscript.Echo[/style] [/style]"Unzipped the new version of the Rent Roll to C:\Rent Roll"[/style] Else[/style] Wscript.Echo[/style] [/style]"Folder does not exist."[/style] install[/style] = [/style]MsgBox[/style] ([/style]"Tenant Tracker not installed..."[/style] & [/style]Chr[/style]([/style]299300) & [/style]"Click Ok to install or Cancel to quit..."[/style],[/style]307308)[/style] [/style]If[/style] intall[/style] = vbOk[/style] [/style]Then[/style] [/style]Set[/style] objSoftware[/style] = objService.Get[/style]([/style]"Win32_Product"[/style])[/style] errReturn[/style] = objSoftware.Install[/style](objFSO.GetParentFolderName[/style](objFile[/style]) & [/style]"TenantTracker2011Full.msi"[/style], , ALL_USERS[/style])[/style] [/style]Else[/style] WScript.Quit[/style] [/style]End[/style] [/style]If[/style] End[/style] [/style]If[/style] [/style] Set[/style] objFSO[/style] = [/style]Nothing[/style] Set[/style] objFolder[/style] = [/style]Nothing[/style] Set[/style] objShell[/style] = [/style]Nothing[/style] [/style] End[/style] [/style]Function[/style] [/style]
|
|
|
|
longbow22
-
Total Posts
:
6
- Scores: 0
-
Reward points
:
0
- Joined: 12/19/2011
-
Status: offline
|
Re:VB Script to zip the file.
Wednesday, December 21, 2011 1:27 AM
( permalink)
Sorry that didnt work either, can someone please delete that? Thanks LB
|
|
|
|