Board logo

标题: [原创]定时杀进程脚本,网吧工作的朋友可能会用得着 [打印本页]

作者: 112183883     时间: 2007-4-29 20:32    标题: [原创]定时杀进程脚本,网吧工作的朋友可能会用得着

你的网吧是不是经常有顾客看PP,下迅雷,听酷狗,把一个本来就风雨飘摇的网络搞得更加动荡?也许你试过诸多方法,也许有效,或许效果不太明显,郁闷之际,不妨再看看下面的东东,或许也是一种思路?

部份代码示例,完整文件请参看附件:

'**********************************************************************************************************
'Description: 定时查杀自定义进程,建议设为开机启动
'Author: 十一狼
'Email: 112183883@qq.com
'QQ: 112183883
'WebSite: http://www.w3cg.net/
'**********************************************************************************************************

Dim scriptPath,lenRootPath,listFilePath
Dim sCheck
scriptPath=WScript.ScriptFullName
lenRootPath=Left(scriptPath,InStrRev(scriptPath,"\"))
listFilePath=lenRootPath & "list.txt"        '设置进程黑名单文件名称
sCheck=10        '设定间隔多少秒钟扫描一次进程
Do
        Call CheckList(listFilePath)
        WScript.Sleep sCheck*1000
Loop

Sub CheckList(listFilePath)
        On Error Resume Next
        Dim Fso,listFile
        Dim KeyWord,processKey,pathKey,TipStr
        Set Fso=CreateObject("Scripting.FileSystemObject")
        If Fso.FileExists(listFilePath) Then
                Set listFile=Fso.OpenTextFile(listFilePath,1,0)
                Do While Not listFile.AtEndOfStream
                        KeyWord=listFile.ReadLine
                        If KeyWord<>"" And Left(KeyWord,1)<>"'" Then
                                KeyWord=Split(KeyWord,"|")
                                If UBound(KeyWord)>1 Then
                                        processKey=Trim(KeyWord(0))
                                        pathKey=Trim(KeyWord(1))
                                        Tipstr=Trim(KeyWord(2))
                                        Call ProcessKiller(processKey,TipStr)
                                        If pathKey<>"" Then Call ProcessKiller(pathKey,TipStr)
                                End If
                        End If
                        If Err Then Err.Clear
                Loop
                Set listFile=Nothing
        Else
                WScript.Quit
        End If
        Set Fso=Nothing
End Sub

Sub ProcessKiller(callstr,Tstr)
        On Error Resume Next
        Dim WMI,objProcess,Process
        Dim MsgStr
        Dim isKilled
        isKilled=False
        Set WMI=GetObject("WinMgmts:")
        Set Process=WMI.InstancesOf("Win32_Process")
        For Each objProcess In Process
                If InStr(callstr,".")>0 Then
                        If objProcess.name=callstr Then
                                objProcess.Terminate
                                isKilled=True
                        End If
                Else
                        If InStr(objProcess.ExecutablePath,callstr)>0 Then
                                objProcess.Terminate
                                isKilled=True
                        End If
                End If
                If Err Then Err.Clear
        Next
        Set Process=Nothing
        Set WMI=Nothing
        MsgStr="对不起,为了营造一个良好的网络环境,本网吧禁止运行以下程序:" & vbCrLf & vbCrLf
        MsgStr=MsgStr & " - " & Tstr & vbCrLf & vbCrLf & "敬请广大顾客朋友理解并配合,谢谢!"
        If isKilled=True Then MsgBox MsgStr
End Sub


最后说下,这种方法对于一般的网民有效,如果遇到内行的人,估计还是一眼就能看穿我们玩的这个把戏了,不过内行的人又有多少人到网吧闲混呢?呵呵。还有一个进程的黑名单列表,如果文件名改了,请在脚本中重新设置文件名,设置的地方见程序注释。
附件 1: ProcessKiller.rar (2007-4-29 20:32, 1.68 K,下载次数: 224)

作者: ieutk     时间: 2007-4-29 21:11
好东东,顶一个!
作者: xiaogen888     时间: 2007-5-2 11:29    标题: 强贴

顶顶顶顶顶
作者: huyingbin     时间: 2007-5-26 17:22
dddd
作者: 08765976     时间: 2007-7-8 06:31
還好啦
作者: lpf2008007     时间: 2007-7-8 14:30
b不错
作者: zhi5252     时间: 2007-7-25 21:48
呵呵不错的喜欢顶个的~
作者: wudixin96     时间: 2007-7-25 21:59
用Terminate
来结束进程不是很好,有些是结束不掉的,如打印机的进程等。
作者: gmsx007     时间: 2007-7-25 22:16    标题: 好东东,是VB的?可惜我还看不懂

好东东,是VB的?可惜我还看不懂,但还是谢了!!
作者: hpwsb     时间: 2007-11-30 22:41
不错,谢谢了