vbs+hta 实现同时关闭多个系统进程

news/2025/2/24 17:35:51
本代码通过 xp mshta.exe 解析执行
-----------------------------------------------------------------------------------
<HEAD>
<title>进程中断</title>
<HTA:APPLICATION
APPLICATIONNAME="进程中断"
BORDER="THICK"
caption="进程中断"
maximizebotton="yes"
minmizebutton="yes"
scroll="yes"
showintaskbar="yes"
singleinstance="yes"
sysmenu="yes"
windowstate="maximize"
>
</HEAD>
<SCRIPT LANGUAGE="VBScript">

Set os0=createobject("shell.application")
Set wmi=GetObject("winmgmts://.")
Set d0=CreateObject("scripting.dictionary")

Sub list
d0.RemoveAll
n=1
dataarea.innerhtml=Nothing
strHTML = strhtml&"<table border='1' style='border-collapse: collapse' "    & _
           "bordercolor='#111111' width='100%' id='Table1' >"
strhtml = strhtml&"<tr>"& _
     "<td width='3%'>"&"<font size=2>"&"序号"&"</font>"&"</td>"& _
     "<td width='20%'>"&"<font size=2>"&"名称"&"</font>"&"</td>"& _
     "<td width='7%'>"&"<font size=2>"&"PID"&"</font>"&"</td>"& _
     "<td width='70%'>"&"<font size=2>"&"命令行"&"</font>"&"</td>"
Set pro_s=wmi.instancesof("win32_process")
For Each p In pro_s
strhtml = strhtml&"<tr>"& "<td width='3%'>"&    _
      "<font size=2>"&n&"</font>"&"</td>"&"<td width='20%'>"& _
      "<font size=2>"&p.name&"</font>"&"</td>"& "<td width='7%'>"& _
      "<font size=2>"&p.handle&"</font>"&"</td>"& "<td width='70%'>"& _
      "<font size=2>"&p.commandline&"</font>" _
      &"</td>"
    
d0.Add ""&n,Trim(p.handle)
n=n+1
Next
dataarea.innerhtml=strhtml
End Sub


Sub stop_p
xs=Split(txt.value,",",-1,1)
for i=0 to ubound(xs) 
for n=0 to ubound(xs)
    if n=i then 
     n=n+1
     if n>ubound(xs) then exit for
    end if
    if xs(n)=xs(i) or _
     Trim(xs(n))="" Then 
     xs(n)="-1"
    end If
next
Next
w=0 
For i=0 To UBound(xs)
If d0.Exists(xs(i))=False Then 
     xs(i)="-2"
     w=w+1
End If
Next
w=(UBound(xs)+1-w)  
If w=0 Then
MsgBox "需要中断的进程序号列表无效,"&Chr(13)& _
     "可能需要关闭的进程不存在或者输入的序号格式不正确,请打开进程列表确认!"
Else
strhtml="<font size=2>"&"已被中断的进程"&"</font>"&"<br>"
strHTML = strhtml&"<table border='1' style='border-collapse: collapse' "    & _
           "bordercolor='#111111' width='100%' id='Table1' >"
For i=0 To UBound(xs)
If xs(i) <> "-2" Then 
Set pro_s=wmi.EXECQUERY("Select * FROM WIN32_PROCESS Where HANDLE='"&D0(XS(I))&"'" )
    N=1
    For Each p In pro_s
       pd=p.terminate()
       If pd=0 Then 
     strhtml = strhtml&"<tr>"& "<td width='3%'>"&"<font size=2>"&xs(i)&"</font>"&"</td>"& _
        "<td width='20%'>"&"<font size=2>"&p.name&"</font>"&"</td>"& _
        "<td width='7%'>"&"<font size=2>"&p.handle&"</font>"&"</td>"& _
        "<td width='70%'>"&"<font size=2>"&p.commandline&"</font>"&"</td>"
     D0.Remove(xs(i))
     n=n+1
       End If
    Next
    If N=0 Then '要关闭的进程可能被牵连关闭了
     strhtml = strhtml&"<tr>"& "<td width='3%'>"&    _
        "<font size=2>"&xs(i)&"</font>"&"</td>"&"<td width='20%'>"& _
        "<font size=2>"&p.name&"</font>"&"</td>"& "<td width='7%'>"& _
        "<font size=2>"&p.handle&"</font>"&"</td>"& "<td width='70%'>"& _
        "<font size=2>"&p.commandline&"     已经被间接关闭"&"</font>"& _
        "</td>"
     D0.Remove(xs(i))
    End if
End If
Next
dataarea.innerhtml=dataarea.innerhtml&strhtml
txt.value=""
End If
End Sub


</SCRIPT>

<body>
<input type="button" value="进程列表" name="list_button"    onClick="list"><p>
<span id="dataarea"></span><br>
输入欲中断的进程序号,如:1,2,5,7,55...
<input type="text" name="txt" size=60 value="">
<input type="button" value="中断进程" name="stop_p_button"    onClick="stop_p">
<p>
</body> 

http://www.niftyadmin.cn/n/2557051.html

相关文章

[bbk4741] 第26集 - 第三章 Flashback Table 03

Flashback Version Query:Considerations The VERSIONS clause cannot be used to query: External tablesTemporary tablesFixed tablesViewsThe VERSIONS clause cannot span DDL commands.Segment shrink operations are filtered out.在哪种情况下可以使用flashback versio…

管理和优化服务的vbs

Dim SS, SDim szMsg, szTtlDim lSet SS GetObject("winmgmts:{impersonationLevelimpersonate}").ExecQuery("Select * From Win32_Service")szMsg "执行了下列操作&#xff1a;" & vbCrLfszTtl "管理服务程序"l Len(szMsg)Fo…

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

监控并中止QQ及QQgame进程&#xff0c;同样可以用于中断其他程序进程&#xff0c;只要将进程的name写入stop_qq.txt 此脚本由 wscript.exe 脚本解析程序负责解析执行. 此脚本是死循环程序&#xff0c;要中断此脚本只需要在STOP_QQ.TXT 中填入含有 “WSCRIPT.EXE” 内容的记录并…

laravel生成控制器

生成控制器 1、生成普通控制器 php artisan make:controller PostController 2、使用RESTFUL生成控制器&#xff08;自动生成index、create、store、show、edit、update、destory方法&#xff09; php artisan make:controller PostController --resource 为RESTFul风格控制器…

教你们怎么查自己的手机信息

拨号界面输入&#xff1a;*#*#4636#*#* 即可 转载于:https://www.cnblogs.com/xieyuan/archive/2013/05/20/3787416.html

IBM 上海 LBS offer入手总结

(这是两年前写在CSDN上的文章&#xff0c;今天找到了转载过来&#xff0c;毕竟是回忆) IBM 上海 LBS offer入手总结 发表于2015/4/24 4:50:04 1109人阅读 今天下午IBM上海那边的team leader给我打电话&#xff0c;说是已经可以给我这个岗位的口头offer了&#xff0c;后面就是走…

程序模式VS2010 C++最简单的检查内存泄露

在写这篇文章之前&#xff0c;xxx已经写过了几篇关于改程序模式主题的文章,想要了解的朋友可以去翻一下之前的文章 每日一道理 生命&#xff0c;是一场漫长的棋局。这盘棋没有猎猎西风&#xff0c;没有四起狼烟&#xff0c;只有在取舍和进退中抉择。只有像棋中的小卒那样&#…

VB future

New features in Visual Basic 10VB10里会有哪些新功能呢? 今天在codeplex 网站看到了一个介绍VB10新功能的文档.&#xff08;http://code.msdn.microsoft.com/vbfuture&#xff09; 下来研究了一下.VB10和VB9比起来没有太多的亮点,只是对实用性方面作了一些改进. 像 Auto-im…