Problem mit taskkill Befehl
Hallo,
ich habe ein Problem mit dem taskkill Befehl.
Und zwar möchte ich ein bestimmtes Programm schließen, WENN es geöffnet ist.
Wenn nicht, soll eine Meldung erscheinen, dass dieses Programm nicht geöffnet war.
Ich möchte das über eine Batch umsetzen.
Bisher habe ich es so gemach:
Allerdings erscheint dann eine Fehlermeldung, falls das Aomei-Backup-Programm garnicht geöffnet war.
Könnt Ihr helfen?
Grüße von
Yan
ich habe ein Problem mit dem taskkill Befehl.
Und zwar möchte ich ein bestimmtes Programm schließen, WENN es geöffnet ist.
Wenn nicht, soll eine Meldung erscheinen, dass dieses Programm nicht geöffnet war.
Ich möchte das über eine Batch umsetzen.
Bisher habe ich es so gemach:
TASKKILL /IM AMBackup.exe /T /F
Allerdings erscheint dann eine Fehlermeldung, falls das Aomei-Backup-Programm garnicht geöffnet war.
Könnt Ihr helfen?
Grüße von
Yan
Please also mark the comments that contributed to the solution of the article
Content-Key: 33501938496
Url: https://administrator.de/contentid/33501938496
Printed on: April 30, 2024 at 22:04 o'clock
7 Comments
Latest comment
Batch
Powershell
Gruß pp.
@echo off
set "process=AMBackup.exe"
tasklist /FI "IMAGENAME eq %process%" | find /i "%process%" >nul 2>&1 && (
echo Killing process '%process%' ...
taskkill /F /IM %process%
) || (
echo Process '%process%' not found.
)
$process = "AMBackup"
if ($proc = Get-Process -Name $process -EA 0){
$proc | stop-process -Force -verbose
}else{
write-warning "Process '$process' not found."
}