Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法只用变量 %username% 杀死当前用户的进程?
假设我已经登录,所以我只想在我的会话中终止进程 cmd.exe 但我需要一个变量。
我试过这个
taskkill /F /FI "%username%" /IM cmd.exe
但这不起作用。
根据taskkill /?您必须在过滤器中提供参数名称。要按用户名过滤,您必须运行
taskkill /?
taskkill /F /FI "USERNAME eq %username%" /IM cmd.exe
确保您正在运行 taskkill 的用户有足够的权限来终止另一个用户的进程。