saber 酱的抱枕

Fly me to the moon

04/14
2016
软件

使用vbs关闭指定的应用程序

Do while(1)
strComputer = "."
set objWMIService = getobject("winmgmts:\\.\root\CIMV2")
Set colProcessList1 = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'LOL.exe'")
For Each objProcess1 in colProcessList1
objProcess1.Terminate()
Next
Wscript.Sleep(1000)
Loop

在知乎上看到的。如果你想“整人”,或者限制别人在你电脑上玩游戏什么的,你可以使用这个vbs文件试试。

这个vbs运行后,将查询指定的程序是否在运行。如果在运行就结束进程,该软件看起来就像闪退了一样。之后每过指定的时间(以毫秒为单位),它都会重复执行以上步骤。

说明与注意事项:
1.支持中文名的进程;
2.运行之后到任务管理器中看是否有"wscript.exe"的进程,每当你运行一次这个vbs,就会产生一个wscript.exe进程。运行一次就行了,不要运行之后没看到有什么反应,就以为运行失败了。
3.这个脚本会一直运行着,如果要停止脚本,结束对应的wscript.exe进程就可以了。

如果你想限制多个程序,可以使用小w改进的代码:

Do while(1)
strComputer = "."
set objWMIService = getobject("winmgmts:\\.\root\CIMV2")
Set colProcessList1 = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'GPU-Z v0.8.3.exe'")
For Each objProcess1 in colProcessList1
objProcess1.Terminate()
Next
Set colProcessList2 = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'GifCam_CHS.exe'")
For Each objProcess1 in colProcessList2
objProcess1.Terminate()
Next
Wscript.Sleep(5000)
Loop

把查询、循环部分(4-7行)复制,修改程序名和colProcessList变量的编号就行。

使用vbs关闭指定的应用程序

  1. Aurora
    TheWorld BrowserTheWorld BrowserWindows 7 x64 EditionWindows 7 x64 Edition

    我难道会说我经常用这个来限制我弟玩游戏 #(滑稽)
    :check
    choice /t 60 /d y /n>nul
    tasklist|find /i "game" && goto start
    goto check

    :start
    choice /t 2000 /d y /n >nul
    taskkill /im Client.exe /f
    taskkill /im Tgame.exe /f && mshta "vbscript:msgbox("CPU过热,已强制退出游戏",,"逆战:温馨提示")(window.close)"
    taskkill /im QQspeed_loader.exe /f
    taskkill /im Gameapp.exe /f && mshta "vbscript:msgbox("指令引用的内存0x00433220不能为read",,"应用程序停止工作")(window.close)"

    :break
    for /l %%i in (1 1 12) do (
    mshta "javascript:document.write();setTimeout('close()',300000)"
    taskkill /im Client.exe /f
    taskkill /im Tgame.exe /f && mshta "vbscript:msgbox("请散热一段时间,以免硬件损坏",,"逆战:温馨提示")(window.close)"
    taskkill /im QQspeed_loader.exe /f
    taskkill /im Gameapp.exe /f && mshta "vbscript:msgbox("请散热一段时间,以免硬件损坏",,"QQ飞车:温馨提示")(window.close)"
    )
    goto check

    回复
  2. locationiskey
    Internet Explorer 11.0Internet Explorer 11.0Windows 7Windows 7

    为什么会是问我啊_(:3」∠)_
    我只记得以前见过一个用bat或者powershell做的
    _(:3」∠)_
    真要弄可以的话……我猜
    Set colProcessList1 = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'LOL.exe'")
    For Each objProcess1 in colProcessList1
    objProcess1.Terminate()
    Next
    Set colProcessList2 = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'CF.exe'")
    For Each objProcess1 in colProcessList2
    objProcess1.Terminate()
    Next
    但是我不太明白这个objProcess1是什么鬼,set objWMIService 又是要干嘛

    回复