-1

I have a batch code that i want to run in vbs, without a cmd window. Batch code:

:X
taskkill /f /im chrome.exe /fi "WINDOWTITLE eq Monkeys*"
goto x

Can anyone help me?

Tried running the file through a seperate batch file and vbs file. VBS code:

Set oShell = CreateObject ("Wscript.Shell") 

Dim strArgs

strArgs = "cmd /c cleaning.bat"

oShell.Run strArgs, 0, false

But i want to run the batch code with a single vbs.

Marcelo Paco
  • 2,732
  • 4
  • 9
  • 26
Pritam
  • 1
  • 1
  • 2
    Just run the TaskKill command directly with the VBScript `Run` method. No need to run Cmd /c. – LesFerch Apr 18 '23 at 20:14
  • Ref: [Run](https://www.vbsedit.com/html/6f28899c-d653-4555-8a59-49640b0e32ea.asp) and [Do Loop](https://www.vbsedit.com/html/4d86d9ea-6b84-4f59-a179-296b5087cdd1.asp) – LesFerch Apr 18 '23 at 20:17
  • Also, add a delay between each call to TaskKill. A loop with no delay hogs a lot of CPU cycles. – LesFerch Apr 19 '23 at 02:45

1 Answers1

-1

The question doesn't cover anything new, so this is just a throw-away answer to help you out:

Set oWSH = CreateObject("Wscript.Shell")
Do
  oWSH.Run "TaskKill /f /im chrome.exe /fi ""WINDOWTITLE eq Monkeys*""",0,True
  WScript.Sleep 1000
Loop
LesFerch
  • 1,540
  • 2
  • 5
  • 21