目前我正在使用这些命令来停止和启动 JAVA.exe
echo start stop wildfly >>.\Restart_wildfly.log
echo Datum = %date% %time% >>.\Restart_wildfly.log
taskkill /F /IM java.exe >>.\Restart_wildfly.log
timeout 20 >nul >>.\Restart_wildfly.log
echo start wildfly >>.\Restart_wildfly.log
net start "Wildfly"
答案1
帖子 taskkill 通过路径区分两张图片 建议通过完整路径而不是图像名称来终止的几种方法:
使用 PowerShell:
(Get-WmiObject Win32_Process | Where-Object { $_.Path.StartsWith('C:\Dir1') }).Terminate()
使用 WMIC:
wmic process where ExecutablePath='C:\\Dir1\\image.exe' delete