我感染了一些恶意软件,发现了该病毒,然后将其删除。
当我打开taskmanager时,我仍然发现病毒进程仍在后台运行。
我使用windows server 2012,并且只有freesshd终端可以与Windows交互,所以我使用powershell命令:
Stop-Process -Name procname -Force
但是它仍然显示在taskmanager中,并每秒自我重复一次。
如何使用powershell或cmd杀死它?
欢迎。 :)
那就是说,尝试一下并可能对其进行调整以适合您的目的:
$logfile = "C:\temp\KillProcesses.txt"
$procName = "<process name here>"
while ($true) {
# get the process
$killproc = get-ciminstance win32_process | where commandline -imatch $procName
# try it first with taskkill
if ($killproc.ProcessId) {
invoke-command -ScriptBlock {cmd /c taskkill /f /PID $killproc.ProcessId} > $logfile 2>&1
} else {
"<log message>" > $logfile
}
# try it again with Powershell
if ($killproc.ProcessId) {
Stop-Process -Id $killproc.ProcessId -Force > $logfile 2>&1
} else {
"<log message>" > $logfile
}
# move it to another name or try to delete it or something
if ($killproc) {
$origpath = ($killproc.CommandLine).tostring().replace("`"","").trim() #might need to parse this for the full path to filename
$killpath = "$origpath.bad"
Move-Item $origpath $killpath > $logfile 2>&1
}
Start-Sleep -Seconds 1
}
随着您了解更多,您可能会在命令周围使用try / catch,甚至学习将类似内容转换为运行服务。
这可以回答问题,但是我仍然认为,摆脱病毒是一个更好的解决方案。不确定您是否希望一直在系统上运行它。 :)