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