I'am trying to find how to close a process using it's title.
I found the command:
taskkill /fi "WINDOWTITLE eq the_title_of_the_windows"
and it works great.
When I try:
oShell.Run "taskkill /fi "WINDOWTITLE eq the_title_of_the_windows"", , True
I get an error and it won't compile.
Any idea on how to use th symbole " in this line?
In order to use double quotation marks inside another pair of double quotation marks, you need to use "" instead of just ", because if you use one quotation mark " it will be considered the end of text between the first and the second quotation marks
So, your code should look like this:
oShell.Run "taskkill /fi ""WINDOWTITLE eq the_title_of_the_windows""", , True
The following example will terminate all processes with window title (Calculator):
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
oShell.Run "taskkill /fi ""WINDOWTITLE eq Calculator""", , True
Hope that helps :)
Alternatively you can try below code: This code will pick the task from Task manager and close the process. Copy pasted the code in ".vbs" File and use call KillAll("your task name.exe")
Function KillAll(ProcessName)
Dim objWMIService, colProcess
Dim strComputer, strList, p
Dim i :i= 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name like '" & ProcessName & "'")
For Each p in colProcess
p.Terminate
i = i+1
Next
MsgBox("Total Instance :: " &i& " of "&ProcessName&" is killed")
End Function
call KillAll("MicrosoftEdge.exe")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With