Rel*_*lla 5 windows zip http batch-file unpack
如何创建.BAT文件以从HTTP服务器下载和解压缩zip文件?
我们有像这样的链接http://example.com/folder.zip和绝对文件夹一样的链接C:\Users\UserName\Some mixed ??????? English Adress\
如果zip中的文件存在于目录中,则对其进行压缩。
仅使用本机Windows(xp vista win7等)BAT功能和文件。
请您添加代码示例。
试试这个混合 bat/vbs 脚本
@echo off
> %temp%\~tmp.vbs echo sUrl = "http://www.unicontsoft.com/file.zip"
>> %temp%\~tmp.vbs echo sFolder = "c:\temp\unzip"
>> %temp%\~tmp.vbs (findstr "'--VBS" "%0" | findstr /v "findstr")
cscript //nologo %temp%\~tmp.vbs
del /q %temp%\~tmp.vbs
goto :eof
'--- figure out temp file & folder
With CreateObject("WScript.Shell") '--VBS
sTempFile = .Environment("Process").Item("TEMP") & "\file.zip" '--VBS
sTempFolder = .Environment("Process").Item("TEMP") & "\file.zip.extracted" '--VBS
End With '--VBS
'--- download
WiTh CreateObject("MSXML2.XMLHTTP") '--VBS
.Open "GET", sUrl, false '--VBS
.Send() '--VBS
If .Status = 200 Then '--VBS
ResponseBody = .ResponseBody '--VBS
With Createobject("Scripting.FileSystemObject") '--VBS
If .FileExists(sTempFile) Then '--VBS
.DeleteFile sTempFile '--VBS
End If '--VBS
End With '--VBS
With CreateObject("ADODB.Stream") '--VBS
.Open '--VBS
.Type = 1 ' adTypeBinary '--VBS
.Write ResponseBody '--VBS
.Position = 0 '--VBS
.SaveToFile sTempFile '--VBS
End With '--VBS
End If '--VBS
End With '--VBS
'--- extract
With CreateObject("Scripting.FileSystemObject") '--VBS
On Error Resume Next '--VBS
.CreateFolder sFolder '--VBS
.DeleteFolder sTempFolder, True '--VBS
.CreateFolder sTempFolder '--VBS
On Error GoTo 0 '--VBS
With CreateObject("Shell.Application") '--VBS
.NameSpace(sTempFolder).CopyHere .NameSpace(sTempFile).Items '--VBS
End With '--VBS
.CopyFolder sTempFolder, sFolder, True '--VBS
.DeleteFolder sTempFile, True '--VBS
.DeleteFile sTempFile, True '--VBS
End With '--VBS
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13382 次 |
| 最近记录: |