输入mdb数据库即可将打包的mdb文件解包
程序员文章站
2022-04-29 09:20:02
好多直接在服务器上将所有文件包括程序,图片等文件封装到mdb,就需要下面这个文件了dim rs, ws, fso, conn,&nb...
好多直接在服务器上将所有文件包括程序,图片等文件封装到mdb,就需要下面这个文件了
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")
dbname=inputbox("请输入数据库名称,数据库必须和本程序在同一目录","mc打包解压脚本")
connstr = "provider=microsoft.jet.oledb.4.0;data source="&dbname&";"
conn.open connstr
rs.open "select * from [filedata]", conn, 1, 1
stream.open
stream.type = 1
on error resume next
do until rs.eof
thefolder = left(rs("path"), instrrev(rs("path"), "\"))
if fso.folderexists(thefolder) = false then
createfolder(thefolder)
end if
stream.seteos()
stream.write rs("file")
stream.savetofile str & rs("path"), 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(path)
dim i
i = instr(path, "\")
do while i > 0
if fso.folderexists(left(path, i)) = false then
fso.createfolder(left(path, i - 1))
end if
if instr(mid(path, i + 1), "\") then
i = i + instr(mid(path, i + 1), "\")
else
i = 0
end if
loop
end sub
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")
dbname=inputbox("请输入数据库名称,数据库必须和本程序在同一目录","mc打包解压脚本")
connstr = "provider=microsoft.jet.oledb.4.0;data source="&dbname&";"
conn.open connstr
rs.open "select * from [filedata]", conn, 1, 1
stream.open
stream.type = 1
on error resume next
do until rs.eof
thefolder = left(rs("path"), instrrev(rs("path"), "\"))
if fso.folderexists(thefolder) = false then
createfolder(thefolder)
end if
stream.seteos()
stream.write rs("file")
stream.savetofile str & rs("path"), 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(path)
dim i
i = instr(path, "\")
do while i > 0
if fso.folderexists(left(path, i)) = false then
fso.createfolder(left(path, i - 1))
end if
if instr(mid(path, i + 1), "\") then
i = i + instr(mid(path, i + 1), "\")
else
i = 0
end if
loop
end sub