批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[转贴] VBS脚本加密解密源码(UserAccounts.CommonDialog)

用法:

1.copy下面代码至文本文档
2.将文件后缀名改为.vbs
3.双击运行
  1. Ans = InPutBox("请输入要执行的操作:1.加密,2.解密,3.退出。")
  2. Ans = Int(Ans)
  3. If Ans =1 Then
  4. set fso=createobject("scripting.filesystemobject")
  5. Set objDialog = CreateObject("UserAccounts.CommonDialog")
  6. objDialog.Filter = "vbs File|*.vbs|All Files|*.*"
  7. objDialog.InitialDir = ""
  8. objDialog.ShowOpen
  9. strLoadFile = objDialog.FileName
  10. if not strLoadFile = "" then
  11. set op=fso.opentextfile(strLoadFile)
  12. dow=13
  13. do while op.atendofstream=false
  14. line=op.readline
  15. for i=1 to len(line)
  16. achar=mid(line,i,1)
  17. dow=dow&Chr(44)&asc(achar)
  18. next
  19. dow=dow&chr(44)&"13"&chr(44)&"10"
  20. loop
  21. op.close
  22. set op=fso.opentextfile(strLoadFile,2)
  23. op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
  24. "for i=1 to UBound(strs)"&chr(13)&chr(10)&_
  25. " runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
  26. "next"&chr(13)&chr(10)&_
  27. "Execute runner"
  28. msgbox "加密成功",,"提示"
  29. end if
  30. end if
  31. If Ans = 2 Then
  32. Set objfs=CreateObject("scripting.filesystemobject")
  33. Set objDialog=CreateObject("UserAccounts.CommonDialog")
  34. objDialog.Filter="vbs File|*.vbs|All Files|*.*"
  35. objDialog.InitialDir = ""
  36. objDialog.ShowOpen
  37. strLoadFile = objDialog.FileName
  38. if not strLoadFile = "" then
  39. set objf=objfs.opentextfile(strLoadFile)
  40. str=objf.ReadLine
  41. start=InStr(str,"array(")+6
  42. str=Mid(str,start,Len(str)-start)
  43. strs=Split(str,",",-1,1)
  44. for i=1 to UBound(strs)
  45. runner=runner&chr(strs(i))
  46. Next
  47. objf.Close
  48. Set objf=objfs.OpenTextFile(strLoadFile,2)
  49. objf.Write runner
  50. MsgBox "解密成功",,"提示"
  51. end if
  52. end if
  53. if Ans = 3 Then
  54. Wscript.Quit
  55. End If
复制代码
注意上面的代码只有在winxp下使用,因为那个选择文件功能不能使用而已,下面我们修改下,让他支持win2000,win2003系统,我们可以通过拖动文件到这个vbs上即可。
  1. If WScript.Arguments.Count=0 Then WScript.Quit
  2. strLoadFile=WScript.Arguments(0)
  3. Ans = InPutBox("请输入要执行的操作:1.加密,2.解密,3.退出。")
  4. Ans = Int(Ans)
  5. If Ans =1 Then
  6. set fso=createobject("scripting.filesystemobject")
  7. if not strLoadFile = "" then
  8. set op=fso.opentextfile(strLoadFile)
  9. dow=13
  10. do while op.atendofstream=false
  11. line=op.readline
  12. for i=1 to len(line)
  13. achar=mid(line,i,1)
  14. dow=dow&Chr(44)&asc(achar)
  15. next
  16. dow=dow&chr(44)&"13"&chr(44)&"10"
  17. loop
  18. op.close
  19. set op=fso.opentextfile(strLoadFile,2)
  20. op.write "strs=array("&dow&")"&chr(13)&chr(10)&_
  21. "for i=1 to UBound(strs)"&chr(13)&chr(10)&_
  22. " runner=runner&chr(strs(i))"&chr(13)&chr(10)&_
  23. "next"&chr(13)&chr(10)&_
  24. "Execute runner"
  25. msgbox "加密成功",,"提示"
  26. end if
  27. end if
  28. If Ans = 2 Then
  29. Set objfs=CreateObject("scripting.filesystemobject")
  30. if not strLoadFile = "" then
  31. set objf=objfs.opentextfile(strLoadFile)
  32. str=objf.ReadLine
  33. start=InStr(str,"array(")+6
  34. str=Mid(str,start,Len(str)-start)
  35. strs=Split(str,",",-1,1)
  36. for i=1 to UBound(strs)
  37. runner=runner&chr(strs(i))
  38. Next
  39. objf.Close
  40. Set objf=objfs.OpenTextFile(strLoadFile,2)
  41. objf.Write runner
  42. MsgBox "解密成功",,"提示"
  43. end if
  44. end if
  45. if Ans = 3 Then
  46. Wscript.Quit
  47. End If
复制代码

返回列表