I need a script that will create a zip file, and add files to it using
VBScript.

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

Re: Creating a zip file without WINZIP by mr_unreliable

mr_unreliable
Tue Apr 10 11:19:27 CDT 2007

As best I can recall, this has already been "asked-and-answered".

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)

PK wrote:
> I need a script that will create a zip file, and add files to it using
> VBScript.
>
> 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

Re: Creating a zip file without WINZIP by Ayush

Ayush
Tue Apr 10 11:27:11 CDT 2007

[PK]s message :
> I need a script that will create a zip file, and add files to it using
> VBScript.

> 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

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

Re: Creating a zip file without WINZIP by PK

PK
Tue Apr 10 12:14:04 CDT 2007

Ayush - thanks for the reply
I get an OBJECT REQUIRED 'ZIPp on line
zip.CopyHere(Fol.Items)



"Ayush" <"ayushmaan.j[aatt]gmail.com" wrote:

> [PK]s message :
> > I need a script that will create a zip file, and add files to it using
> > VBScript.
>
> > 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
>
> 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
>

Re: Creating a zip file without WINZIP by PK

PK
Tue Apr 10 12:48:03 CDT 2007

OK - I think I am almost there, but need a little help to bring it home...

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



Re: Creating a zip file without WINZIP by PK

PK
Tue Apr 10 13:26:01 CDT 2007

GOT IT!

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)


Re: Creating a zip file without WINZIP by Frank

Frank
Tue Jul 03 14:50:05 CDT 2007

What does the "myHex" do, or what is it for?
Tks


"PK" <PK@discussions.microsoft.com> wrote in message
news:DE13B047-1DB9-45E7-B414-421B91F285AA@microsoft.com...
> GOT IT!
>
> 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)
>


Re: Creating a zip file without WINZIP by Jimbo

Jimbo
Wed Jul 04 06:26:29 CDT 2007

this is a ridiculous attempt at writing PK to a text file, and then NOT
creating a zip file. i suggest the person that wrote this mess stick to perl
as its obvious thats where he comes from



"Frank B Smith" <fbsmith@telus.net> wrote in message
news:8D1D8D1B-C001-4FF1-9806-E30D374345EF@microsoft.com...
> What does the "myHex" do, or what is it for?
> Tks
>
>
> "PK" <PK@discussions.microsoft.com> wrote in message
> news:DE13B047-1DB9-45E7-B414-421B91F285AA@microsoft.com...
>> GOT IT!
>>
>> 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)
>>
>


Re: Creating a zip file without WINZIP by Gottfried

Gottfried
Wed Jul 04 07:39:42 CDT 2007

As far as I can see, it creates a valid (empty) ZIP File.

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:
> What does the "myHex" do, or what is it for?
> Tks
>
>
> "PK" <PK@discussions.microsoft.com> wrote in message
> news:DE13B047-1DB9-45E7-B414-421B91F285AA@microsoft.com...
>> GOT IT!
>>
>> 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)
>>
>