Pages

Saturday, 25 February 2023

Process

 # Define an array of process names

 $processNames = @("process_name_1", "process_name_2", "process_name_3")

 # Loop through the process names and check if they are running
 
 foreach ($processName in $processNames) {
     if (Get-Process $processName -ErrorAction SilentlyContinue) {
 
         Write-Host "$processName is running."
         # If the process is running, close it
 
         Stop-Process -Name $processName -Force
 
         Write-Host "$processName has been closed."
 
     }
 
     else {
 
         Write-Host "$processName is not running."
 
     }
 
 }
 
 

No comments:

Post a Comment

test

 # Set the file path you want to check $filePath = "C:\Path\To\Your\File.exe" # Check if file exists if (Test-Path $filePath) {   ...

Search This Blog