Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Programme, die beendet werden sollen
- $appsToClose = @(
- "programm1",
- "programm2",
- "programm3"
- )
- # Funktion zum sicheren Beenden von Prozessen
- function Close-Applications {
- param (
- [string[]]$processNames
- )
- foreach ($processName in $processNames) {
- $processes = Get-Process -Name $processName -ErrorAction SilentlyContinue
- if ($processes) {
- Write-Host "Beende $processName..."
- try {
- $processes | Stop-Process -Force
- Write-Host "$processName wurde erfolgreich beendet."
- }
- catch {
- $errorMessage = $_.Exception.Message
- Write-Warning ("Fehler beim Beenden von " + $processName + ": " + $errorMessage)
- }
- }
- else {
- Write-Host "$processName läuft nicht."
- }
- }
- }
- # Benutzer informieren
- Write-Host "Beginne mit dem Beenden der Programme..."
- # Programme beenden
- Close-Applications -processNames $appsToClose
- Write-Host "Fertig! Alle Programme wurden beendet."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement