大漠荒颜

记录一个青海油田子弟生活的点点滴滴

VBS代码可视化结束进程程序

| |
01:13 , 北纬36度
无意间,在一论坛,看见这样的一段代码,觉得写的很有想法,拿来和大家分享下。




On Error Resume Next

Set Shell = CreateObject("Wscript.Shell")
Set App = CreateObject("Shell.Application")


Do

        App.MinimizeAll

        Num = 0
        Data = ""

        Set Add = CreateObject("Scripting.Dictionary")

        For Each Test in GetObject("Winmgmts:{ImpersonationLevel=Impersonate,(Backup)}!\\.\Root\Cimv2:Win32_Process").Instances_
                If Db1 <> Test.Name Then
                        Num = Num + 1
                        Select Case Num
                                Case 1
                                        Str = 5
                                Case 10
                                        Str = 4
                                Case 100
                                        Str = 3
                        End Select
                        Data = Data + Chr(32) & Num & Chr(41) & String(Str,Chr(32)) & Test.Name & Chr(13)
                        Add.Add Num , Test.Handle
                End If
                Db1 = Test.Name
        Next

        Do
                Enter = InputBox(Data,"Kill Process GUI (c) By Small flower"," Enter process num.",9800,100)

                If Enter <> "" Then
                        If Enter < 0 Then
                                Exit Do
                        Else
                                For I = Enter To Enter
                                        If Add(I) <> "" Then
                                                A = 0
                                                B = 0
                                                C = 0
                                                For Each Test in GetObject("Winmgmts:{ImpersonationLevel=Impersonate,(Backup)}!\\.\Root\Cimv2").ExecQuery("Select * From Win32_Process Where Handle=" & Add(I))
                                                        A = A + 1
                                                        If Test.Terminate = 0 Then
                                                                B = B + 1
                                                        Else
                                                                C = C + 1
                                                        End If
                                                Next
                                                Shell.Popup "All:" & A & ",Success:" & B & ",Lose:" & C , 1 , "By Small flower"
                                                Exit Do
                                        Else
                                                Shell.Popup " Error,not process num :( " , 1 , "By Small flower"
                                                Exit Do
                                        End If
                                Next
                        End If
                Else
                        Wscript.Quit
                End If
        Loop
        Set Add = Nothing
Loop
类别:MY IT TEXT | Tags: , | 0 条评论, 1235 次阅读
网友评论(0):
发表评论:

昵称: 
电邮:
网址: