如何讓.bat檔案在彈出警告框時自動運行?

如何讓.bat檔案在彈出警告框時自動運行?

有時 POP Peeper 突然無法在我的計算機上運作。每當發生這種情況時,都會彈出一個警告框,任務管理器中該警告框的PID為244。我知道如何使用.bat檔案來重新啟動程序,但不知道如何使該檔案在彈出警報框時自動運行。

誰能教我怎麼做?
以下是有問題的警報框。 在此輸入影像描述

答案1

下面的腳本應該做你想做的事,即當彈出視窗出現時關閉它,然後重新啟動另一個進程

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    i = x 
    Do While i = x
        Set colProcesses = objWMIService.ExecQuery _
            ("Select * from Win32_Process Where Name = 'notepad.exe'")
            '("Select * from Win32_Process Where Name = 'Name of Your process you are waiting for to start'")

    If colProcesses.Count = 0 Then
        'It does not exist do nothing
    Else
        For Each objProcess in colProcesses
            'this will close the process you were watching, as soon as it starts
            objProcess.Terminate()

                'Closing the process you want to restart
                Set colProcesses = objWMIService.ExecQuery _
                 ("SELECT * FROM Win32_Process WHERE Name = 'winword.exe'")
                 '("SELECT * FROM Win32_Process WHERE Name = 'name of the process you want to terminate'")
                For Each objProcess2 in colProcesses
                 objProcess2.Terminate()
                Next

            Dim objShell
            Set objShell = WScript.CreateObject( "WScript.Shell" )

            objShell.Run("""C:\Program Files (x86)\Internet Explorer\iexplore.exe""")
            'objShell.Run("""process or application you want to start""")
            Set objShell = Nothing

        Next
    End If

Loop

相關內容