当前位置: 移动技术网 > IT编程>脚本编程>VBScript > VBS 添加右键计算文件MD5的实现代码

VBS 添加右键计算文件MD5的实现代码

2017年12月08日  | 移动技术网IT编程  | 我要评论

李浩贞,吕运计,网球宝贝官网

最近相关的备份比较频繁,为了校验文件的完整性,老是要打开某文件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

脚本如运行出错,请下载并注册

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网