Enter the MDB database to unpack the packaged MDB file _vbs

Source: Internet
Author: User
Tags mdb database unpack
A lot of directly on the server all files including programs, pictures and other files packaged into an MDB, you need the following file
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 ("Please enter the database name, the database must be in the same directory as this program", "MC Package Decompression Script")
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 "All Files released!"

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.