当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > unpack.vbs

VBScript
VBS教程:VBscript语句-Execute 语句
VBS教程:VBscript语句-Erase 语句
VBS教程:VBscript语句-Do...Loop 语句
VBS教程:VBscript语句-Dim 语句
VBS教程:VBscript语句-Const 语句
VBS教程:VBscript语句-Class 语句
VBS教程:VBscript语句-Call 语句
VBS教程:VBscript语句-功能介绍
VBS教程:VBscript属性-Value 属性
VBS教程:VBscript属性-Source 属性
VBS教程:VBscript属性-Pattern 属性
VBS教程:VBscript属性-Number 属性
VBS教程:VBscript属性-Length 属性
VBS教程:VBscript属性-IgnoreCase 属性
VBS教程:VBscript属性-HelpFile 属性
VBS教程:VBscript属性-HelpContext 属性
VBS教程:VBscript属性-Global 属性
VBS教程:VBscript属性-FirstIndex 属性
VBS教程:VBscript属性-Description 属性
VBS教程:VBscript属性-功能介绍

VBScript 中的 unpack.vbs


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 232 ::
收藏到网摘: n/a

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