[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[原创] 来看看写脚本时都能调用哪些对象

本帖最后由 wankoilz 于 2013-4-19 22:25 编辑

这是阅读Demon's Blog的文章 "VBS深入CreateObject函数" 后练手写的
运行后得到一个txt,里面罗列了你电脑上脚本可以调用的COM对象,献丑了各位!
  1. '查看写脚本时都能调用哪些COM对象
  2. 'From bbs.bathome.net BY wankoilz
  3. '参考 http://demon.tw/copy-paste/vbs-createobject-internal.html
  4. Option Explicit
  5. Dim fso,wshell,reg,f
  6. Dim fullname,colmatch,match,Submatch
  7. Dim i,str,result
  8. Set fso=CreateObject("scripting.filesystemobject")
  9. Set wshell=CreateObject("wscript.shell")
  10. fullname=GetPath(WScript.ScriptFullName)&"ProgrammableObjects.txt"
  11. wshell.Popup "稍等几秒钟...",2,"prompt"
  12. wshell.Run "reg export hkcr\clsid "&""""&fullname&""""&" /y",0,True
  13. Set f=fso.OpenTextFile(fullname,1,True,True)
  14. str=f.ReadAll():f.Close
  15. Set reg=New RegExp
  16. reg.Global=True
  17. reg.IgnoreCase=True
  18. reg.Pattern="ProgID\]\r\n@=(.*?)\r\n\r\n(.*?)Programmable"
  19. Set colmatch=reg.Execute(str)
  20. For Each match In colmatch
  21.     result=result&match.Submatches(0)&vbCrLf&vbCrLf
  22. Next
  23. result=Replace(result,"""","")
  24. fso.CreateTextFile(fullname,True,True).Write(result)
  25. wshell.Run fullname
  26. Function GetPath(fullname)
  27.     Dim arrTmp,i
  28.     arrTmp=Split(fullname,"\")
  29.     For i=0 To UBound(arrTmp)-1
  30.         GetPath=GetPath&arrTmp(i)&"\"
  31.     Next
  32. End Function
复制代码
参考:http://demon.tw/copy-paste/vbs-createobject-internal.html,Demon's Blog值得一看!!

To 3#:
我这里运行没问题...
To 4#:
抱歉,之前没注意那个链接。
我本身实力比较浅,读过那篇文章后闲来为练手才写这么个东东,代码不对的地方还请Demon指点,以免我误认子弟,感谢。

TOP

感谢Demon兄回复。
这样一来别人看到帖子的时候就不会被误导了。
那么代码中罗列出来的只是部分对象了,但数目已经很多。

TOP

我是win7,xp没试过。不过我觉得学习到如何查看可调用对象的方法就是了,vbs写出来不复杂的。

TOP

返回列表