0

I write a batch script to kill process, here is it

@echo off
IF "%1" NEQ "" (
   Set "process=%1.exe"
   echo "killing process %process%"
   taskkill /F /IM %process% /T
)

I name it to mkill.cmd.

C:\Users\Administrator>mkill chrome
"killing process "
ERROR: Invalid syntax.
Type "TASKKILL /?" for usage.

C:\Users\Administrator>mkill chrome
"killing process chrome.exe"
SUCCESS: The process with PID 8892 (child process of PID 7732 ) has been terminated.
SUCCESS: The process with PID 4024 (child process of PID 7732 ) has been terminated.

C:\Users\Administrator>mkill telegram
"killing process chrome.exe"
Error: The process "chrome.exe" not found. 

C:\Users\Administrator>mkill test
"killing process telegram.exe"
SUCCESS: The process with PID 2896 (child process of PID 3952 ) has been terminated.

It seems it has a delay in parameter pass. What's the problem?

Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
  • 2
    I have closed your question as it is a very common issue, which is answered almost daily. I might add however, that you can modify your script to bypass the issue too, _(by not setting a variable needlessly)_: `@If Not "%~1" == "" (`, `Echo "killing process %~1"`, and `"%__APPDIR__%taskkill.exe" /F /IM "%~1.exe" /T)`. – Compo Feb 20 '20 at 16:54
  • @Compo Thank you very much, I have searched my question with keyword `delay` very hard but not got into any of those questions. Your link is really helphul. – Ynjxsjmh Feb 20 '20 at 17:27

0 Answers0