Stop-Process command hangs

I am running Stop-Process -processname WESClient as part of deployment script and on 32 bit machines it runs fine but on 64 bit machines it hangs on this command and I eventually just need to end the script. Below is what is in the log when it hangs.

[Pre-Installation] :: Display balloon tip notification with message [Installation started.]. Show-BalloonTip 10/21/2015 3:54:26 PM 3388 (0x0D3C)
[Pre-Installation] :: Spin up progress dialog in a separate thread with message: [Installation in progress. Please wait…]. Show-InstallationProgress 10/21/2015 3:54:27 PM 3388 (0x0D3C)

Any ideas? I need this process stopped as part of this install.

Hi Jamie,
The log you’ve displayed shows only a small part of the whole story. can you please post the code you’re using in the Deploy-application.ps1 file, whatever custom code you’re using in that file.

This script performs the installation or uninstallation of an application(s).
The script is provided as a template to perform an install or uninstall of an application(s).
The script either performs an “Install” deployment type or an “Uninstall” deployment type.
The install deployment type is broken down into 3 main sections/phases: Pre-Install, Install, and Post-Install.
The script dot-sources the AppDeployToolkitMain.ps1 script which contains the logic and functions required to install or uninstall an application.
.PARAMETER DeploymentType
The type of deployment to perform. Default is: Install.
Specifies whether the installation should be run in Interactive, Silent, or NonInteractive mode. Default is: Interactive. Options: Interactive = Shows dialogs, Silent = No dialogs, NonInteractive = Very silent, i.e. no blocking apps. NonInteractive mode is automatically set if it is detected that the process is not user interactive.
.PARAMETER AllowRebootPassThru
Allows the 3010 return code (requires restart) to be passed back to the parent process (e.g. SCCM) if detected from an installation. If 3010 is passed back to SCCM, a reboot prompt will be triggered.
.PARAMETER TerminalServerMode
Changes to “user install mode” and back to “user execute mode” for installing/uninstalling applications for Remote Destkop Session Hosts/Citrix servers.
.PARAMETER DisableLogging
Disables logging to file for the script. Default is: $false.
Deploy-Application.ps1 -DeployMode ‘Silent’
Deploy-Application.ps1 -AllowRebootPassThru -AllowDefer
Deploy-Application.ps1 -DeploymentType Uninstall
Toolkit Exit Code Ranges:
60000 - 68999: Reserved for built-in exit codes in Deploy-Application.ps1, Deploy-Application.exe, and AppDeployToolkitMain.ps1
69000 - 69999: Recommended for user customized exit codes in Deploy-Application.ps1
70000 - 79999: Recommended for user customized exit codes in AppDeployToolkitExtensions.ps1
Param (
[string]$DeploymentType = ‘Install’,
[string]$DeployMode = ‘Interactive’,
[switch]$AllowRebootPassThru = $false,
[switch]$TerminalServerMode = $false,
[switch]$DisableLogging = $false

Try {
## Set the script execution policy for this process
Try { Set-ExecutionPolicy -ExecutionPolicy ‘ByPass’ -Scope ‘Process’ -Force -ErrorAction ‘Stop’ } Catch {}

## Variables: Application
[string]$appVendor = 'iManage'
[string]$appName = 'Filesite'
[string]$appVersion = '9.2 64 bit'
[string]$appArch = ''
[string]$appLang = 'EN'
[string]$appRevision = '01'
[string]$appScriptVersion = '2.0.0'
[string]$appScriptDate = '08/17/2015'
[string]$appScriptAuthor = '&lt;author name&gt;'

##* Do not modify section below
#region DoNotModify

## Variables: Exit Code
[int32]$mainExitCode = 0

## Variables: Script
[string]$deployAppScriptFriendlyName = 'Deploy Application'
[version]$deployAppScriptVersion = [version]'3.6.5'
[string]$deployAppScriptDate = '08/17/2015'
[hashtable]$deployAppScriptParameters = $psBoundParameters

## Variables: Environment
If (Test-Path -LiteralPath 'variable:HostInvocation') { $InvocationInfo = $HostInvocation } Else { $InvocationInfo = $MyInvocation }
[string]$scriptDirectory = Split-Path -Path $InvocationInfo.MyCommand.Definition -Parent

## Dot source the required App Deploy Toolkit Functions
Try {
	[string]$moduleAppDeployToolkitMain = "$scriptDirectory\AppDeployToolkit\AppDeployToolkitMain.ps1"
	If (-not (Test-Path -LiteralPath $moduleAppDeployToolkitMain -PathType 'Leaf')) { Throw "Module does not exist at the specified location [$moduleAppDeployToolkitMain]." }
	If ($DisableLogging) { . $moduleAppDeployToolkitMain -DisableLogging } Else { . $moduleAppDeployToolkitMain }
Catch {
	If ($mainExitCode -eq 0){ [int32]$mainExitCode = 60008 }
	Write-Error -Message "Module [$moduleAppDeployToolkitMain] failed to load: <code>n$($_.Exception.Message)</code>n `n$($_.InvocationInfo.PositionMessage)" -ErrorAction 'Continue'
	## Exit the script, returning the exit code to SCCM
	If (Test-Path -LiteralPath 'variable:HostInvocation') { $script:ExitCode = $mainExitCode; Exit } Else { Exit $mainExitCode }

##* Do not modify section above
If ($deploymentType -ine 'Uninstall') {
	[string]$installPhase = 'Pre-Installation'
	## Show Welcome Message, close Internet Explorer if required, allow up to 3 deferrals, verify there is enough disk space to complete the install, and persist the prompt
	Show-InstallationWelcome -AllowDeferCloseApps 'iexplore,outlook,winword,excel,metadataassistant' -PromptToSave -BlockExecution -DeferTimes 4 -CheckDiskSpace -PersistPrompt
	## Show Progress Message (with the default message)
	## &lt;Perform Pre-Installation tasks here&gt;
    Stop-Process -processname WESClient
	Execute-MSI -Action Uninstall -Path 'MA4Enterprise4.0.1307.msi' -Parameters '/QB'
    Execute-MSI -Action Uninstall -Path 'MA4Enterprise4.1.msi' -Parameters '/QB'
    Execute-MSI -Action Uninstall -Path 'MA5Enterprise.msi' -Parameters '/QB'
    Execute-MSI -Action Uninstall -Path 'MilanClientInstaller3.0.25.msi' -Parameters '/QB'
    Execute-MSI -Action Uninstall -Path 'Prosperoware.Milan.ClientInstaller352TC248.msi' -Parameters '/QB'
	[string]$installPhase = 'Installation'
	## Handle Zero-Config MSI Installations
	If ($useDefaultMsi) {
		[hashtable]$ExecuteDefaultMSISplat =  @{ Action = 'Install'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
		Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) { $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ } }
	## &lt;Perform Installation tasks here&gt;
	Execute-Process -Path "$dirFiles\FileSite 9.2 (x86)\setup.exe" -Parameters '/s /v"/qb SERIALNUMBER="02003-0132154"'
    Execute-Process -Path 'MA5Enterprise.exe' -Parameters '/s /v" /qn"'
    Execute-MSI -Action Install -Path 'Prosperoware.Milan.ClientInstaller352TC248.msi' -Parameters '/QB MILAN_URL="http://Milan/milan/clientpages" ADDLOCAL="Commands"'
    reg import $dirFiles\LM_Updated_Milan_Menus_64bit.reg
    reg import $dirFiles\LM_InterwovenSettings_64bit.reg
	[string]$installPhase = 'Post-Installation'
	## &lt;Perform Post-Installation tasks here&gt;
	## Display a message at the end of the install
	If (-not $useDefaultMsi) { Show-InstallationPrompt -Message 'Installation is complete.' -ButtonRightText 'OK' -Icon Information -NoWait }
ElseIf ($deploymentType -ieq 'Uninstall')
	[string]$installPhase = 'Pre-Uninstallation'
	## Show Welcome Message, close Internet Explorer with a 60 second countdown before automatically closing
	Show-InstallationWelcome -CloseApps 'iexplore' -CloseAppsCountdown 60
	## Show Progress Message (with the default message)
	## &lt;Perform Pre-Uninstallation tasks here&gt;
	[string]$installPhase = 'Uninstallation'
	## Handle Zero-Config MSI Uninstallations
	If ($useDefaultMsi) {
		[hashtable]$ExecuteDefaultMSISplat =  @{ Action = 'Uninstall'; Path = $defaultMsiFile }; If ($defaultMstFile) { $ExecuteDefaultMSISplat.Add('Transform', $defaultMstFile) }
		Execute-MSI @ExecuteDefaultMSISplat
	# &lt;Perform Uninstallation tasks here&gt;
	[string]$installPhase = 'Post-Uninstallation'
	## &lt;Perform Post-Uninstallation tasks here&gt;


## Call the Exit-Script function to perform final cleanup operations
Exit-Script -ExitCode $mainExitCode

Catch {
[int32]$mainExitCode = 60001
[string]$mainErrorMessage = “$(Resolve-Error)”
Write-Log -Message $mainErrorMessage -Severity 3 -Source $deployAppScriptFriendlyName
Show-DialogBox -Text $mainErrorMessage -Icon ‘Stop’
Exit-Script -ExitCode $mainExitCode

Have you tried with the parameter -Force?
Stop-Process -processname WESClient -Force

-Force did not make a difference. What I did just notice is that the process is a user process and I am running the install with Administrator rights. Is there a way for me to close this process as a different user/logged in user?

As long as you’re running with admin credentials you shouldn’t have an issue closing other users’ processes.
I did notice one bug in your script.

Stop-Process -processname WESClient

should be

Stop-Process -name WESClient

Stop Process Technet Article

Not sure why that would work in 64 but not 32 bit.

I’m seeing the same problem. In my deploy-application code I’ve got:

Stop-Process -Name "pimuninstall" -force

However it never stops the process from running. Both are running in the system context through software center.

I define the processes to be stopped on the Show-InstallationWelcome line and let it do it for me. It reads and processes those even when the deployment is run silently

I don’t understand why you’re using stop-process.
Here’s what I’m doing :

[string]$appCloseApps = 'notepad++'
Show-InstallationWelcome -CloseApps $appCloseApps -CloseAppsCountdown 120 -CheckDiskSpace -PersistPrompt