After prowling google, and checking an old thread in ServerFault, I thought I would try here. Without any additional downloads, on a fresh install of XP SP3, how can I run a script to extract AND zip a file into a .zip?

People have tried saying to use third party utilities, but that requires downloading a program as well, and making sure they're in the same location all the time. I don't want to download the Microsoft Resource Kit just for this one chunk of functionality on multiple computers

link|improve this question

feedback

2 Answers

up vote 1 down vote accepted

You can do this with VBScript. This question has been asked on Stack Overflow, and this answer comes from Jay:

Dim fso, winShell, MyTarget, MySource, file
Set fso = CreateObject("Scripting.FileSystemObject")
Set winShell = createObject("shell.application")


MyTarget = Wscript.Arguments.Item(0)
MySource = Wscript.Arguments.Item(1)

Wscript.Echo "Adding " & MySource & " to " & MyTarget

'create a new clean zip archive
Set file = fso.CreateTextFile(MyTarget, True)
file.write("PK" & chr(5) & chr(6) & string(18,chr(0)))
file.close

winShell.NameSpace(MyTarget).CopyHere winShell.NameSpace(MySource).Items

do until winShell.namespace(MyTarget).items.count = winShell.namespace(MySource).items.count
    wscript.sleep 1000 
loop

Set winShell = Nothing
Set fso = Nothing
link|improve this answer
feedback

I believe that Windows XP does have a built in function for this called Compact.

COMPACT

link|improve this answer
That does not create a .zip file; that just added the Compress attribute to the file/directory – Luke Sep 28 '11 at 4:43
My mistake, i thought that worked. – kobaltz Sep 28 '11 at 4:49
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.