I can not use anything other than the built-in functions in Win XP SP2
(I can NOT use winzip or any other utility)
Anyone have anything on this?
Thanks
http://groups.google.com/advanced_group_search
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
This works:
FolderToZip = "C:\CygWin"
zipFile = "C:\some.zip"
set sa = CreateObject("Shell.Application")
Set zip= sa.NameSpace(zipFile)
Set Fol=sa.NameSpace(FolderToZip)
zip.CopyHere(Fol.Items)
WScript.Sleep 2000
Good Luck, Ayush.
--
Script Center-Script Repository : http://snipurl.com/Script_Repository
I have a working script that will zip up an entire directory - how would i
modify this to zip a single file instead of the entire dir?
(watch for screen wrap)
Option Explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim MySource, MyTarget, MyZipName, MyHex, MyBinary, i
Dim oShell, oApp, oFolder, oCTF, oFile
Dim oFileSys
'MySource = "C:\DBMaintenance"
'MyTarget = "c:\SinkFolder.zip"
MySource = "C:\Documents and Settings\myusername\Desktop\ZIP
Test\FullFile.mdb"
MyTarget = "C:\Documents and Settings\myusername\Desktop\ZIP Test\Backup of
FullFile.zip"
MyHex = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0)
For i = 0 To UBound(MyHex)
MyBinary = MyBinary & Chr(MyHex(i))
Next
Set oShell = CreateObject("WScript.Shell")
Set oFileSys = CreateObject("Scripting.FileSystemObject")
'Create the basis of a zip file.
Set oCTF = oFileSys.CreateTextFile(MyTarget, True)
oCTF.Write MyBinary
oCTF.Close
Set oCTF = Nothing
Set oApp = CreateObject("Shell.Application")
'Copy the files to the compressed folder
Set oFolder = oApp.NameSpace(MySource)
If Not oFolder Is Nothing Then
oApp.NameSpace(MyTarget).CopyHere oFolder.Items
End If
'Wait for compressing to begin, this was necessary on my machine
wScript.Sleep(5000)
'wait for lock to release
Set oFile = Nothing
On Error Resume Next
Do While (oFile Is Nothing)
'Attempt to open the file, this causes an Err 70, Permission Denied when the
file is already open
Set oFile = oFileSys.OpenTextFile(MyTarget, ForAppending, False)
If Err.number <> 0 then
Err.Clear
wScript.Sleep 3000
End If
Loop
Set oFile=Nothing
Set oFileSys=Nothing
Here is my script which nicely creates a zip file and puts a file in it:
Option Explicit
Const FOF_SIMPLEPROGRESS = 256
Dim MySource, MyTarget, MyHex, MyBinary, i
Dim oShell, oCTF
Dim oFileSys
dim winShell
MySource = "C:\Documents and Settings\c9pxk1\Desktop\ZIP Test\FullFile.mdb"
MyTarget = "C:\Documents and Settings\c9pxk1\Desktop\ZIP Test\Backup of
FullFile.zip"
MyHex = Array(80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0)
For i = 0 To UBound(MyHex)
MyBinary = MyBinary & Chr(MyHex(i))
Next
Set oShell = CreateObject("WScript.Shell")
Set oFileSys = CreateObject("Scripting.FileSystemObject")
'Create the basis of a zip file.
Set oCTF = oFileSys.CreateTextFile(MyTarget, True)
oCTF.Write MyBinary
oCTF.Close
Set oCTF = Nothing
'Add File to zip
set winShell = createObject("shell.application")
winShell.namespace(MyTarget).CopyHere MySource
wScript.Sleep(5000)
"PK" <P...@discussions.microsoft.com> wrote in message
news:DE13B047-1DB9-45E7...@microsoft.com...
"Frank B Smith" <fbs...@telus.net> wrote in message
news:8D1D8D1B-C001-4FF1...@microsoft.com...
The script uses the abilities of Windows Explorer to handle "Zip
Folders" as "normal" Folders. It creates an empty Zip file and then
copies the Files to be compressed into the "Folder" (that's what the
Line [winShell.namespace(MyTarget).CopyHere MySource] does).
HTH
Gottfried
Frank B Smith schrieb: