How to kill a single process on multiple workstati

2019-08-17 17:43发布

I'm trying to write a .bat file that can look at clients that are in a file (hosts.txt) and see if calculator is running and kill it or them but it keeps say there are not instances found.

@echo off
cd \
for /F "tokens=1-2" %%a in ("hosts.txt") do (
wmic /node:%%a process where name='Calculator.exe' call terminate
)

What would be a better way of doing this or what am I missing?

1条回答
再贱就再见
2楼-- · 2019-08-17 18:00

My comment as an answer, (one line only):

@WMIC /Node:@hosts.txt Process Where "Name='calc.exe'" Call Terminate

The answer assumes you have privileges to do so, you may need to include /user:privilegedusername and /password:privilegeduserpassword.

查看更多
登录 后发表回答