0

I'm trying to make a script in PowerShell which calls a .bat (& .\test.bat) and this .bat needs to execute a .exe (or many), wait a timeout, and kill it (or them).

For this purpose I did (in a loop):

start %1
timeout 5 > nul
taskkill /f /im %1
exit 0

Everything is launched and the timeout is good but the cmd is never closed.

How could I do it?

Mofi
  • 46,139
  • 17
  • 80
  • 143
77140B
  • 41
  • 6

1 Answers1

0

You could try use ex: Stop-Process -processname notepad.exe