最近相关的备份比较频繁,为了校验文件的完整性,老是要打开某文件HASH校验工具,比较麻烦,于是乎写了这个东东,文件较大时计算有点慢,文件的MD5值保存在剪贴板!效果如图:
使用方法:
1.先将GetMD5.reg文件导入注册表以添加右键菜单,GetMD5.reg代码如下:
复制代码 代码如下:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\HASH(&G)\command]
@="WScript.exe //nologo c:\\windows\\system32\\GetMD5.vbs \"%1\""
2.复制GetMD5.vbs到c:\windows\system32\,即完成所有操作,GetMD5.vbs代码如下:
复制代码 代码如下:
Public MD5Value
MD5Sum(WScript.Arguments(0))
SetClipboardText("MD5: " & MD5Value & ", FilePath: " & WScript.Arguments(0))
Function MD5Sum(filename)
Dim MyStream, MyHashed, MD5Value
Set MyStream = CreateObject("ADODB.Stream")
MyStream.Type = 1
MyStream.Open()
MyStream.LoadFromFile(filename)
Set MyHashed = CreateObject("CAPICOM.HashedData")
MyHashed.Algorithm = 3
MyHashed.Hash(MyStream.Read())
MyStream.Close
MD5Value = MyHashed.Value
End Function
Sub SetClipboardText(Text)
Dim Word
Set Word = CreateObject("Word.Application")
Word.Documents.Add
Word.Selection.Text = Text
Word.Selection.Copy
Word.Quit False
End Sub
脚本如运行出错,请下载并注册CAPICOM组件