toupaizouguang,兵天血地,梦回古朝
压缩代码:
zip "d:\test.iso", "d:\test.zip"
zip "d:\test", "d:\test.zip"
msgbox "ok"
sub zip(byval mysourcedir, byval myzipfile)
set fso = createobject("scripting.filesystemobject")
if fso.getextensionname(myzipfile) <> "zip" then
exit sub
elseif fso.folderexists(mysourcedir) then
ftype = "folder"
elseif fso.fileexists(mysourcedir) then
ftype = "file"
filename = fso.getfilename(mysourcedir)
folderpath = left(mysourcedir, len(mysourcedir) - len(filename))
else
exit sub
end if
set f = fso.createtextfile(myzipfile, true)
f.write "pk" & chr(5) & chr(6) & string(18, chr(0))
f.close
set objshell = createobject("shell.application")
select case ftype
case "folder"
set objsource = objshell.namespace(mysourcedir)
set objfolderitem = objsource.items()
case "file"
set objsource = objshell.namespace(folderpath)
set objfolderitem = objsource.parsename(filename)
end select
set objtarget = objshell.namespace(myzipfile)
intoptions = 256
objtarget.copyhere objfolderitem, intoptions
do
wscript.sleep 1000
loop until objtarget.items.count > 0
end sub
解压缩代码:
unzip "d:\test.iso", "d:\test.zip"
msgbox "ok"
sub copyfolder(byval mysourcedir, byval mytargetdir)
set fso = createobject("scripting.filesystemobject")
if not fso.folderexists(mysourcedir) then
exit sub
elseif not fso.folderexists(mytargetdir) then
fso.createfolder(mytargetdir)
end if
set objshell = createobject("shell.application")
set objsource = objshell.namespace(mysourcedir)
set objfolderitem = objsource.items()
set objtarget = objshell.namespace(mytargetdir)
intoptions = 256
objtarget.copyhere objfolderitem, intoptions
end sub
用vbs解压zip文件,网上搜到的多数是调用winrar,一点技术含量也没有。google一下“vbs 解压zip”,第二是搜搜问问“vbs实现解压缩zip文件”,满意答案是“所以想用vbs来解压这两种格式的文件,至少要有两种命令行解压工具,否则是绝对不可以的”。绝对不可以的,回答的人好自信啊,笑而不语~
原文:http://demon.tw/programming/vbs-zip-file.html
http://demon.tw/programming/vbs-unzip-file.html
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
-
-
用vbs实现文本循环读取
因为测试中需要读取一批url数据进行浏览,其实使用qtp本身的table能实现多种读取方式,但是因为需要tabel是使用excel保存的,在没有...
[阅读全文]
-
-
-
-
-
-
-
网友评论