欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

unpack.vbs

程序员文章站 2022-03-21 15:30:48
dim rs, ws, fso, conn, stream, connstr, thefolderset rs = createobject("adodb.recordse...

dim rs, ws, fso, conn, stream, connstr, thefolder
set rs = createobject("adodb.recordset")
set stream = createobject("adodb.stream")
set conn = createobject("adodb.connection")
set fso = createobject("scripting.filesystemobject")
connstr = "provider=microsoft.jet.oledb.4.0;data source=hytop.mdb;"

conn.open connstr
rs.open "filedata", conn, 1, 1
stream.open
stream.type = 1

on error resume next

do until rs.eof
 thefolder = left(rs("thepath"), instrrev(rs("thepath"), "\"))
 if fso.folderexists(thefolder) = false then
  createfolder(thefolder)
 end if
 stream.seteos()
 stream.write rs("filecontent")
 stream.savetofile str & rs("thepath"), 2
 rs.movenext
loop

rs.close
conn.close
stream.close
set ws = nothing
set rs = nothing
set stream = nothing
set conn = nothing

wscript.echo "所有文件释放完毕!"

sub createfolder(thepath)
 dim i
 i = instr(thepath, "\")
 do while i > 0
  if fso.folderexists(left(thepath, i)) = false then
   fso.createfolder(left(thepath, i - 1))
  end if
  if instr(mid(thepath, i + 1), "\") then
   i = i + instr(mid(thepath, i + 1), "\")
   else
   i = 0
  end if
 loop
end sub