1

Many times I'll have multiple .hta files running, but only want to terminate a specific one. In Task Manager they are all named mshta.exe *32 under the Processes tab, but if I click the Applications tab I'm able to identify the specific .htas to terminate by seeing their unique Titles. For instance, in the image below you see the the .hta is named "Review Menu". But in the next image you see it's hidden amongst the other running .htas all named mshta.exe *32 in Processes tab.

Is there a command similar to TASKKILL /F /IM mshta.exe that I can use that will specify just to close "Review Menu" instances? Thanks in advance.

Applications Tab:

one

ProcessesTab:

two

Mathomatic
  • 899
  • 1
  • 13
  • 38
  • Please see [this post](http://stackoverflow.com/q/14042537/1169519), it contains a rough example of how to use [WMI](https://msdn.microsoft.com/en-us/library/aa394582%28v=vs.85%29.aspx) to kill a process. – Teemu Aug 10 '15 at 16:08
  • Did you mean that you want like a killer selector ? – Hackoo Aug 16 '15 at 00:52

2 Answers2

1

You can do this in dos prompt:

taskkill /F /IM mshta.exe /fi "WINDOWTITLE eq Review Menu"
TSnake41
  • 405
  • 3
  • 8
0

You can try this vbscript : KillerSelector.vbs

Option Explicit
Dim Titre,Copyright,fso,ws,NomFichierLog,temp,PathNomFichierLog,OutPut,Count,strComputer
Copyright = "[(c) Hackoo (c) 2014 ]"
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject( "Wscript.Shell" )
NomFichierLog="Process WScript.txt"
temp = ws.ExpandEnvironmentStrings("%temp%")
PathNomFichierLog = temp & "\" & NomFichierLog
Set OutPut = fso.CreateTextFile(temp & "\" & NomFichierLog,1)
Count = 0 
strComputer = "."
'Call Find("wscript.exe")
Call Find("mshta.exe")
Call Explorer(PathNomFichierLog)
'***************************************************************************************************
Function Explorer(File)
    Dim ws
    Set ws = CreateObject("wscript.shell")
    ws.run "Explorer "& File & "\",1,True
end Function
'***************************************************************************************************
Sub Find(MyProcess)
    Dim colItems,objItem,Process,Question
    Titre = " Process "& DblQuote(MyProcess) &" running "
    Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _
    & "Where Name like '%"& MyProcess &"%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48)
    For Each objItem in colItems
        Count= Count + 1
        Process = Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2) 'Extraction du chemin du script en ligne de commande
        Process = Replace(Process,chr(34),"")
        Question = MsgBox ("Do you want to stop this application : "& DblQuote(Process) &" ?" ,VBYesNO+VbQuestion,Titre+Copyright)
        If Question = VbYes then
            objItem.Terminate(0)'Kill this Process
            OutPut.WriteLine DblQuote(Process)
        else
            Count= Count - 1 'décrementer le compteur de -1
        End if
    Next
OutPut.WriteLine String(100,"*")
OutPut.WriteLine count & Titre & "were stopped !"
End Sub
'**********************************************************************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'**********************************************************************************************
Hackoo
  • 18,337
  • 3
  • 40
  • 70