监控并中止QQ及QQgame进程 的vbs 脚本

来源:互联网 发布:c语言右移运算符 编辑:程序博客网 时间:2024/05/11 19:08
监控并中止QQ及QQgame进程,同样可以用于中断其他程序进程,只要将进程的name写入stop_qq.txt
'此脚本由 wscript.exe 脚本解析程序负责解析执行.
'此脚本是死循环程序,要中断此脚本只需要在STOP_QQ.TXT 中填入含有 “WSCRIPT.EXE” 内容的记录并保存(Ctrl+S),脚本会将自身中断。
'当程序中断以后再删除 "wscript.exe" 数据,以确保下次能够正常发挥作用。

on error resume      next
Set os0=createobject("shell.application")
Set os=CreateObject("wscript.shell")
Set fs=CreateObject("scripting.filesystemobject")
Set wmi=GetObject("winmgmts://.")
pathx=fs.GetFile(WScript.scriptFullName).ParentFolder.Path
path0=fs.GetFile(WScript.scriptFullName).Path
Set path1=fs.GetSpecialFolder(1)
'--------------------------------------------------------------------------------
'----------------MAIN DO LOOP --------------------------------------------------
Do 
'create_boot
Set d0=createobject("scripting.dictionary")
edit_d
stop_p
WScript.Sleep 5000
Loop

'---------------------------------------------------------------------------------
'-------安装启动项
Sub create_boot
If fs.FolderExists(path1&"/vbs") = False Then fs.CreateFolder path1&"/vbs"
fs.CopyFile path0 , path1&"/vbs/boot.vbs",True
If fs.FileExists(pathx&"/stop_qq.txt")      Then fs.CopyFile pathx&"/vbs/stop_qq.txt" , path1&"/stop_qq.txt",true
os.RegWrite "HKLM/Software/Microsoft/Windows/CurrentVersion/Run/stop_qq", Chr(34)&path1&"/vbs/BOOT.vbs"+Chr(34)
End Sub
'---------------------------------------------------------------------------------
'----------将数据文件中的数据导入dictionary d0
sub      edit_d
If fs.FileExists(pathx&"/stop_qq.txt") = False Then 
        build_f
End If
Set file1=fs.OpenTextFile(pathx&"/stop_qq.txt",1,false)
n=0
Do Until file1.AtEndOfLine
l1=Trim(file1.readline)
If l1 <> "" Then 
      d0.Add n,l1 'd0为公用 dictionary 所以在总程序中定义
      n=n+1
End If
Loop
If n=0 Then build_f
End Sub
'---------------------------------------------------------------------------------
'-------创建数据文件
Sub build_f
Set file1=fs.OpenTextFile(pathx&"/stop_qq.txt",2,True)
file1.WriteLine "qq.exe"
file1.WriteLine "qqgame.exe"
file1.Close
End Sub
'---------------------------------------------------------------------------------
'--------中断进程
Sub stop_p
For Each item In      d0.Items
Set p=wmi.execquery("select * from win32_process where name='"&item&"'")
For Each p0 In p
      p0.terminate()
      os0.MinimizeAll
      os.popup "你不知道工作时间不允许运行此程序么?",1,"警告",64+0
Next
Next
End sub
 
原创粉丝点击