| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| On Error Resume Next |
| Public CurrentFlowInt, ProFlag |
| |
| ConnectionID = "本地连接" |
| |
| Set ObjectNetwork = CreateObject("Wscript.Network") |
| strComputer = ObjectNetwork.ComputerName |
| |
| |
| Set ObjectWSH = Wscript.createObject("Wscript.shell") |
| Set ObjWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") |
| |
| Set NetCards = ObjWMIService.ExecQuery("Select * from Win32_NetworkAdapter WHERE NetConnectionID='" & ConnectionID & "'") |
| If NetCards.count<>0 Then |
| For Each NetCard In NetCards |
| WScript.Echo "Name: " & NetCard.Name & " MACAddress: " & NetCard.MACAddress |
| NetCardName = NetCard.Name |
| strNet = Split(NetCard.Name, " ", -1, 1) |
| str1 = strNet(0) & strNet(1) & strNet(2) |
| Next |
| Else |
| Wscript.Echo "网卡不存在." |
| WScript.Quit(0) |
| End If |
| |
| |
| Set CheckProcess = ObjWMIService.ExecQuery("Select * from Win32_Process WHERE Name='Thunder.exe'") |
| If CheckProcess.count<>0 Then |
| ProFlag = 0 |
| Else |
| ProFlag = 1 |
| End If |
| |
| Set colMonitoredProcesses = objWMIService.ExecNotificationQuery("select * from __instancecreationevent " & " within 1 where TargetInstance isa 'Win32_Process'") |
| |
| i = 0 |
| Do While i = 0 |
| Set CheckProcess = ObjWMIService.ExecQuery("Select * from Win32_Process WHERE Name='Thunder.exe'") |
| If CheckProcess.count<>0 Then |
| |
| Wscript.Echo "迅雷已运行." |
| |
| CurrentFlow |
| BeginFlow = CurrentFlowInt |
| |
| Wscript.Echo "BeginFlow: " & BeginFlow |
| WScript.Sleep 120000 |
| |
| |
| Else |
| Wscript.Echo "迅雷未运行." |
| Set objLatestProcess = colMonitoredProcesses.NextEvent |
| |
| If objLatestProcess.TargetInstance.Name = "Thunder.exe" Then |
| Wscript.Echo "迅雷已运行." |
| CurrentFlow |
| BeginFlow = CurrentFlowInt |
| |
| Wscript.Echo "BeginFlow: " & BeginFlow |
| WScript.Sleep 120000 |
| |
| End If |
| End If |
| |
| CurrentFlow |
| EndFlow = CurrentFlowInt |
| |
| Wscript.Echo "EndFlow: " & EndFlow |
| |
| Result = EndFlow - BeginFlow |
| If Result<20480 Then |
| |
| WScript.Echo "关闭系统." |
| ObjectWSH.Run"shutdown.exe -s -t 0", 0, TRUE |
| End If |
| |
| |
| WScript.Echo "Exit ..." |
| WScript.Quit(0) |
| Loop |
| |
| |
| Function CurrentFlow |
| Set ObjectFlows = objWMIService.InstancesOf("Win32_PerfRawData_Tcpip_NetworkInterface") |
| For Each ObjectFlow In ObjectFlows |
| strNetName = Split(ObjectFlow.Name, " ", -1, 1) |
| str2 = strNetName(0) & strNetName(1) & strNetName(2) |
| If str1 = str2 Then |
| CurrentFlowInt = ObjectFlow.BytesReceivedPersec |
| End If |
| Next |
| End FunctionCOPY |