Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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)))

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

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

Set winShell = Nothing
Set fso = Nothing
share|improve this answer

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


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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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