PSAppDeployToolkit / PSAppDeployToolkit

Project Homepage & Forums
https://psappdeploytoolkit.com
GNU Lesser General Public License v3.0
1.85k stars 491 forks source link

Extended CloseApps (feature request) #81

Open AcidUser85 opened 9 years ago

AcidUser85 commented 9 years ago

Hello,

Sometimes there is need to close only specific process, which may be running multiple with same name. For example you have a PC running multiple java applications. Of course there will be multiple javaw.exe processes running. But those differ by process parameters such as working directory, arguments, path, etc. During install and uninstall it is needed to close only particular process, not all java applications. What if application executable name is the same as other important windows process? In this case -CloseApps also cannot be used, but if there would be setting to specify location of running executable and/or working directory, etc, it would close exactly required processes. Would be great to have such options in newer versions. I had such smart close conflicting processes in my own written vbscript deployment wrapper, but some time ago we decided to migrate to PSAppDeployToolkit and my powershell knownledge is poor to implement this.

That-Annoying-Guy commented 9 years ago

I did something like this but I had to use WMI b/c Get-Process does not return the CommandLine

[System.Array]$popupTasks = Get-WmiObject Win32_Process -Filter "name = 'Powershell.exe'" | select CommandLine, ProcessId

ForEach ($popupTask in $popupTasks) {
    If ( $($popupTask.CommandLine) -match "POPUP" ) {
        Write-Host "Killing [$($popupTask.CommandLine)] "
        Write-Host $popupTask.ProcessId
        Stop-Process -Id $($popupTask.ProcessId) -Force
    }
}
amotaz commented 8 years ago

I really like this, and I've developed some code for this, but it will fundementally change the Show-InstallWelcome function so, I'll add the code in once we're ready for V4

sintaxasn commented 6 years ago

This issue was moved to https://discourse.psappdeploytoolkit.com/t/extended-closeapps-feature-request/1231