If I change this:
echo.
taskkill /f /im "%%i"
echo.
To this:
echo "%%i"
Then I get this:
D:\Test Data>listtask
"sihost.exe"
"taskhostw.exe"
"Pen_TabletUser.exe"
"Pen_TouchUser.exe"
"avpui.exe"
"ShellExperienceHost.exe"
"SearchUI.exe"
"RuntimeBroker.exe"
"TabTip.exe"
"SettingSyncHost.exe"
"nvtray.exe"
"NvBackend.exe"
"MSASCuiL.exe"
"RAVCpl64.exe"
"CorelCreatorClient.exe"
"SetPoint.exe"
"KHALMNPR.exe"
"OneDrive.exe"
"chrome.exe"
"chrome.exe"
"chrome.exe"
"chrome.exe"
"E_IATIGJE.EXE"
"ProductUpdater.exe"
"WzPreloader.exe"
"LWS.exe"
"GalaxyClient.exe"
"GalaxyClient"
"GOG"
"jucheck.exe"
"CodeprojectReputation.exe"
"wlmail.exe"
"wlcomm.exe"
"PSPad.exe"
"conhost.exe"
Press any key to continue . . .
D:\Test Data>
Which would indicate that the batch file works just fine, except in your case for terminating tasks - for obvious reasons I'm not going to try that on my computer!
Trying the command itself by adding
)
taskkill /f /im "pspad.exe"
pause
To the end kills the task perfectly happily.
So I'd suspect that it's a permissions problem.
Try the same thing I did, and echo all the running tasks. Then manually kill the first one. See if it works. But ... there are a lot of tasks in my list that would probably make my computer a little unstable if killed - and yours is likely the same.
Why are you trying to do this?