首页 > 解决方案 > Windows批量获取参数延迟

问题描述

我写了一个批处理脚本来杀死进程,就是这样

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

我把它命名为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.

参数传递似乎有延迟。有什么问题?

标签: batch-file

解决方案


推荐阅读