VBS GET file MD5 value (no component) _vbs

Source: Internet
Author: User
Tags md5

The following code does not require a component to get the MD5 value.

Copy Code code as follows:

Option Explicit
Dim WI
Dim file
Dim file_size
Dim file_attributes
Dim file_version
Dim File_hash
Set WI = CreateObject ("Windowsinstaller.installer")
File = "111.exe"
File_size = wi. FileSize (file)
File_attributes = wi. FileAttributes (file)
File_version = wi. FileVersion (file)
File_hash = Getfilehash (file)
Set WI = Nothing
MsgBox "File:" & File & VbCrLf & _
"Size:" & File_size & VbCrLf & _
"Attributes:" & File_attributes & VbCrLf & _
"Version:" & File_version & VbCrLf & _
"MD5:" & File_hash
Function Getfilehash (file_name)
Dim File_hash
Dim Hash_value
Dim I
Set File_hash = wi. Filehash (file_name, 0)
Hash_value = ""
For i = 1 to File_hash. FieldCount
Hash_value = Hash_value & Bigendianhex (File_hash. Integerdata (i))
Next
Getfilehash = Hash_value
Set File_hash = Nothing
End Function
Function Bigendianhex (INT)
Dim result
Dim B1, B2, B3, B4
result = Hex (Int)
B1 = Mid (result, 7, 2)
B2 = Mid (Result, 5, 2)
B3 = Mid (result, 3, 2)
B4 = Mid (result, 1, 2)
Bigendianhex = b1 & b2 & B3 & B4
End Function

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.