如何在XP的命令行中压缩文件而无需额外的工具/下载


0

在谷歌徘徊,并检查ServerFault中的旧线程后,我想我会尝试这里。在没有任何额外下载的情况下,在全新安装的XP SP3上,如何运行脚本来将文件解压缩并压缩为.zip?

人们试图说使用第三方实用程序,但这也需要下载程序,并确保它们始终位于同一位置。我不想仅为多台计算机上的这一块功能下载Microsoft Resource Kit

Answers:


1

你可以用VBScript做到这一点。这个问题已在Stack Overflow上被问到,这个答案来自周杰伦

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

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.