Answer on running silent mode with serviceUI

Hello guys,

I have a question for you. Currently I am egregiously using this command to start software installation from Intune

ServiceUI.exe Deploy-Application.exe

however, when starting the program, it first asks me whether or not I want to continue with the installation and then if the affected app is open it asks me whether or not to close it.

I would like him in case he does not find the app open to automatically proceed with the installation.

is this possible?

Thanks :wink:

Yes you can absolutely do that (I have just done the same myself for a few apps),
You would need to wrap the installation in an If statement to detect if the app is already running within your Deploy-Application.ps1, I will use Visual Studio Code in my example,
Below the Pre-Installation section I have wrapped the Installation in an If statement to detect if the Visual Studio Code executable ‘Code’ is running (N.B. My new / additional lines are marked with: -> )

        ##*===============================================
        ##* PRE-INSTALLATION
        ##*===============================================
        [String]$installPhase = 'Pre-Installation'

->        if (get-process Code) {
->	    $AppRunning = $true
	    ## 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 -CloseApps 'Code=Visual Studio Code' -BlockExecution -MinimizeWindows $false -AllowDefer -DeferTimes 3 -CheckDiskSpace -PersistPrompt -TopMost $true


Then below the Execute-MSI command I have closed the If statement

                Execute-MSI @ExecuteDefaultMSISplat; If ($defaultMspFiles) {
                    $defaultMspFiles | ForEach-Object { Execute-MSI -Action 'Patch' -Path $_ }
                }
            }
->	} else {
->	    $AppRunning = $false
->	}

        ## <Perform Installation tasks here>
->	Execute-Process -Path "$($dirFiles)\VSCodeSetup-x64.exe" -Parameters '/SP- /VERYSILENT /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /NORESTART /MERGETASKS="!runcode,addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath" /LOG="C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\WWFUK-VisualStudioCode_Install.log"'

        ##*===============================================
        ##* POST-INSTALLATION
        ##*===============================================
        [String]$installPhase = 'Post-Installation'

        ## <Perform Post-Installation tasks here>
	
->	if ($AppRunning -eq $true) {
            ## Display a message at the end of the install
            If (-not $useDefaultMsi) {
                Show-InstallationPrompt -Message "Installation completed successfully.`r`nYou may now use Microsoft Visual Studio Code (version: 1.78.1)" -ButtonRightText "OK" -Icon Information -NoWait
            }
->	}

This would result in a silent install (no prompts for the user) but only if the app being installed was not already running

N.B. you may wish to modify your install as follows:

ServiceUI.exe -Process:explorer.exe Deploy-Application.exe -DeploymentType "Install"

Note: The -Process:explorer switch is used to determine where the install runs i.e. in the context of where explorer.exe is running (The user context), The -DeploymentType is optional, but will by default be the Install command if not specified
You can also use the following to uninstall:

ServiceUI.exe -Process:explorer.exe Deploy-Application.exe -DeploymentType "Uninstall"
1 Like

Hello Adrian,

thank you for your reply.

i’ve tried to implement your code on my script, but not function. can you help me?

<#
.SYNOPSIS

PSApppDeployToolkit - This script performs the installation or uninstallation of an application(s).

.DESCRIPTION

- 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.

PSApppDeployToolkit is licensed under the GNU LGPLv3 License - (C) 2023 PSAppDeployToolkit Team (Sean Lillis, Dan Cunningham and Muhammad Mashwani).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

.PARAMETER DeploymentType

The type of deployment to perform. Default is: Install.

.PARAMETER DeployMode

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 Desktop Session Hosts/Citrix servers.

.PARAMETER DisableLogging

Disables logging to file for the script. Default is: $false.

.EXAMPLE

powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeployMode 'Silent'; Exit $LastExitCode }"

.EXAMPLE

powershell.exe -Command "& { & '.\Deploy-Application.ps1' -AllowRebootPassThru; Exit $LastExitCode }"

.EXAMPLE

powershell.exe -Command "& { & '.\Deploy-Application.ps1' -DeploymentType 'Uninstall'; Exit $LastExitCode }"

.EXAMPLE

Deploy-Application.exe -DeploymentType "Install" -DeployMode "Silent"

.INPUTS

None

You cannot pipe objects to this script.

.OUTPUTS

None

This script does not generate any output.

.NOTES

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

.LINK

https://psappdeploytoolkit.com
#>


[CmdletBinding()]
Param (
    [Parameter(Mandatory = $false)]
    [ValidateSet('Install', 'Uninstall', 'Repair')]
    [String]$DeploymentType = 'Install',
    [Parameter(Mandatory = $false)]
    [ValidateSet('Interactive', 'Silent', 'NonInteractive')]
    [String]$DeployMode = 'Interactive',
    [Parameter(Mandatory = $false)]
    [switch]$AllowRebootPassThru = $false,
    [Parameter(Mandatory = $false)]
    [switch]$TerminalServerMode = $false,
    [Parameter(Mandatory = $false)]
    [switch]$DisableLogging = $false
)

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

    ##*===============================================
    ##* VARIABLE DECLARATION
    ##*===============================================
    ## Variables: Application
    [String]$appVendor = ''
    [String]$appName = 'OBS Studio'
    [String]$appVersion = '29.1.1'
    [String]$appArch = ''
    [String]$appLang = 'MUL'
    [String]$appRevision = '01'
    [String]$appScriptVersion = '1.0.0'
    [String]$appScriptDate = '10/05/2023'
    [String]$appScriptAuthor = 'Myname'
    ##*===============================================
    ## Variables: Install Titles (Only set here to override defaults set by the toolkit)
    [String]$installName = ''
    [String]$installTitle = 'OBS Studio '
	## Variables: Wrapper
	[string] $mybusiness_appfriendlyName	= $appName
	[string] $mybusiness_ProcToClose		= 'obs64'
	[string] $mybusiness_ProcToCloseNonUI	= ''
	[string] $mybusiness_ProcToBlock		= $mybusiness_ProcToClose
	[string] $mybusiness_GetProcess		= $mybusiness_ProcToClose
	[int32]  $mybusiness_FreeSpace		= '1200'
	[boolean]$mybusiness_CheckForReboot	= $false
	[boolean]$mybusiness_ShowBalloonTips	= $true
	[boolean]$configShowBalloonNotifications = $mybusiness_ShowBalloonTips
	[boolean]$mybusiness_UseDialogs		= $true
	[boolean]$mybusiness_AllowDefer		= $true
	[Boolean]$mybusiness_AllowRebootPassThru	=$false
	[string] $mybusiness_Layout			= 'Full'
	[string] $mybusiness_SoftIdent		= "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\OBS Studio [DisplayVersion = 29.1.1]"
	[boolean]$mybusiness_SetBrandingReg	= $true
	[string] $mybusiness_Portfv			= 'OBS'
	[string] $mybusiness_AppAddInfo01	= 'NA'
	[string] $mybusiness_AppAddInfo02	= 'NA'
	[string] $mybusiness_AppAddInfo03	= 'NA'
	[string] $mybusiness_AppAddInfo04	= 'NA'

	[string] $mybusiness_appFullName		= $appVendor + "_" + $appName + "_" + $appArch + "_" + $appVersion + "-" + $appRevision + "_" + $appLang
	[string] $logName				= $mybusiness_appFullName + "_" + $deploymentType + ".log"

#endregion VARIABLE DECLARATION

    ##* Do not modify section below
    #region DoNotModify

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

    ## Variables: Script
    [String]$deployAppScriptFriendlyName = 'Deploy Application'
    [Version]$deployAppScriptVersion = [Version]'3.9.3'
    [String]$deployAppScriptDate = '02/05/2023'
    [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: `n$($_.Exception.Message)`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
        }
    }

#endregion

	
#region CUSTOM APPLICATION VARIABLES AND FUNCTIONS
	#*====================================CUSTOM APPLICATION VARIABLES BEGIN=========================================================

	#*====================================CUSTOM APPLICATION VARIABLES END===========================================================

	#*====================================CUSTOM APPLICATION FUNCTIONS BEGIN=========================================================

	#*====================================CUSTOM APPLICATION FUNCTIONS END===========================================================
#endregion CUSTOM APPLICATION VARIABLES AND FUNCTIONS

 #region INSTALLATION
    If ($deploymentType -ine 'Uninstall' -and $deploymentType -ine 'Repair') {
        ##*===============================================
        ##* PRE-INSTALLATION BEGIN
        ##*===============================================
        [String]$installPhase = 'Pre-Installation'

        # check for pending reboot and stop script execution on true with exit code 1641, if not running in task sequence.
		if ($mybusiness_CheckForReboot){
			Set-Reboot -ForceExitScript -OnlyOnPendingReboot -MandatoryDeviceRestart
		}

		# user dialogs (deprecated)
		if ($mybusiness_UseDialogs){
			if ($mybusiness_AllowDefer){
				Show-InstallationWelcome -AllowDefer -DeferTimes 4
			}
			if ($mybusiness_ProcToClose) {
				Show-InstallationWelcome -CheckDiskSpace -RequiredDiskSpace "$mybusiness_FreeSpace" -CloseApps "$mybusiness_ProcToClose" -AllowDeferCloseApps -DeferTimes 4
			}
			if ($mybusiness_ProcToCloseNonUI) {
				Show-InstallationWelcome -CheckDiskSpace -RequiredDiskSpace "$mybusiness_FreeSpace" -CloseApps "$mybusiness_ProcToCloseNonUI" -Silent
			}
			if ($mybusiness_ProcToBlock) {
				Show-InstallationWelcome -CloseApps "$mybusiness_ProcToBlock" -AllowDeferCloseApps -DeferTimes 4 -BlockExecution
			}
			if (get-process $mybusiness_GetProcess) 	{
				$AppRunning = $true
				Show-InstallationWelcome -CloseApps "$mybusiness_ProcToBlock" -BlockExecution -MinimizeWindows $false -AllowDefer -DeferTimes 4 -CheckDiskSpace -PersistPrompt -TopMost $true 
			}	
		}

        ####################################################################### Upgrade Handle #########################################################################
			
        ## Show Progress Message (With a Message to Indicate the Application is Being Uninstalled)
        Show-InstallationProgress -StatusMessage "Rimozione della versione precedente di OBS Studio in corso. Attendere prego..." -WindowLocation 'BottomRight'
		
		################################################ UPGRADE HANDLE ####################################################################
		## Remove Any Existing Versions of OBS Studio
        Remove-MSIApplications "OBS Studio"
		
		##RemoveOLDBrandings
		Remove-Branding -InstanceName "*Obs*" -AdditionalRegPaths "HKLM:\Software\$($mybusiness_CurrentRegWow)mybusiness\InstalledProducts","HKLM:\Software\$($mybusiness_CurrentRegWow)mybusiness\CM"
		
		## Cleanup OBS Studio Program Files (x86) Directory (If Present)
        If (Test-Path -Path "$envProgramFilesX86\obs-studio\") {
        Write-Log -Message "Cleanup OBS Studio Program Files (x86) Directory."
        Remove-Item -Path "$envProgramFilesX86\obs-studio\" -Force -Recurse -ErrorAction SilentlyContinue 
        }
        ## Remove OBS Studio Desktop Shortcut (If Present)
        If (Test-Path -Path "$envCommonDesktop\OBS Studio.lnk") {
        Write-Log -Message "Removing OBS Studio Desktop Shortcut."
        Remove-Item -Path "$envCommonDesktop\OBS Studio.lnk" -Force -Recurse -ErrorAction SilentlyContinue 
        }
        ## Remove OBS Studio Start Menu Shortcuts (If Present)
        If (Test-Path -Path "$envAllUsersProfile\Microsoft\Windows\Start Menu\Programs\OBS Studio*") {
        Write-Log -Message "Removing OBS Studio Start Menu Shortcuts."
        Remove-Item -Path "$envAllUsersProfile\Microsoft\Windows\Start Menu\Programs\OBS Studio*" -Force -Recurse -ErrorAction SilentlyContinue 
        }
		
		## Install Visual C++ 2015-2022 x64 Redistributable
		Write-Log -Message 'Visual C++ 2015-2022 x64 Redistributable' -Severity 2 -Source $deployAppScriptFriendlyName
	  	Execute-process -path "$dirfiles\VC_redist.x64.exe" -Parameters "/install /quiet /norestart" -WindowStyle Hidden
		Write-Log -Message 'Installation of Visual C++ 2015-2022 x64 Redistributable is successful.' -Severity 2 -Source $deployAppScriptFriendlyName
		

		#*====================================PRE-INSTALLATION END==================================================================
	#endregion PRE-INSTALLATION

	#region MAIN-INSTALLATION
        [String]$installPhase = 'Installation'
		#*====================================MAIN-INSTALLATION BEGIN==================================================================
		
		# user dialogs (deprecated)
		if ($mybusiness_UseDialogs){
			## Only use for longer installations (Installation duration approx. >3 minutes)
			#Show-InstallationProgress -WindowLocation 'BottomRight'
		}
		
		else {
	    $AppRunning = $false
		}
	
		## Show Progress Message (With a Message to Indicate the Application is Being Uninstalled)
		Show-InstallationProgress -StatusMessage "Installazione di OBS Studio in corso. Attendere prego..." -WindowLocation 'BottomRight'
		
        Write-Log -Message 'Start Installation OBS Studio' -Severity 2 -Source $deployAppScriptFriendlyName 
	   
		Execute-Process -Path "$DirFiles\OBS-Studio-29.1.1-Full-Installer-x64.exe" -Parameters "/S" -WindowStyle Hidden

		Write-Log -Message 'Installation of OBS Studio is successful.' -Severity 2 -Source $deployAppScriptFriendlyName

		#*====================================MAIN-INSTALLATION END==================================================================
	#endregion MAIN-INSTALLATION

	#region POST-INSTALLATION
        [String]$installPhase = 'Post-Installation'
		#*====================================POST-INSTALLATION BEGIN==================================================================
		
		## Suppress Auto-Configuration Wizard & Disable Auto Updates
        $INI = Get-ChildItem -Path "$dirFiles" -Include global.ini -File -Recurse -ErrorAction SilentlyContinue
        If($INI.Exists)
        {
        Write-Log -Message "Copying global.ini To User Profiles to Suppress Auto-Configuration Wizard & Disable Auto Updates"
        $UserProfiles = Get-WmiObject Win32_UserProfile | Where {(!$_.Special) -and $_.LocalPath -notlike 'C:\Windows\ServiceProfiles*'} | Select-Object -ExpandProperty LocalPath
        ForEach ($Profile in $UserProfiles) {

        New-Item "$Profile\AppData\Roaming\obs-studio\" -ItemType Directory -Force
        Copy-Item $INI -Destination "$Profile\AppData\Roaming\obs-studio\" -ErrorAction SilentlyContinue
        }
		}
		## Remove OBS Studio Desktop Shortcut (If Present)
        If (Test-Path -Path "$envCommonDesktop\OBS Studio.lnk") {
        Write-Log -Message "Removing OBS Studio Desktop Shortcut."
        Remove-Item -Path "$envCommonDesktop\OBS Studio.lnk" -Force -Recurse -ErrorAction SilentlyContinue 
        }
		
        ## Branding Install
		Set-Branding
		#*====================================POST-INSTALLATION END==================================================================
	#endregion POST-INSTALLATION

#endregion INSTALLATION

#region UNINSTALLATION		
    }   ElseIf ($deploymentType -ieq 'Uninstall') {
		
	#region PRE-UNINSTALLATION
	
        [String]$installPhase = 'Pre-Uninstallation'
		##*====================================PRE-UNINSTALLATION BEGIN============================================================
		
        # check for pending reboot and stop script execution on true with exit code 1641, if not running in task sequence.
		if ($mybusiness_CheckForReboot){
			Set-Reboot -ForceExitScript -OnlyOnPendingReboot -MandatoryDeviceRestart
		}

		# user dialogs (deprecated)
		if ($mybusiness_UseDialogs){
			if ($mybusiness_AllowDefer){
				Show-InstallationWelcome -AllowDefer -DeferTimes 4
			}
			if ($mybusiness_ProcToClose) {
				Show-InstallationWelcome -CheckDiskSpace -RequiredDiskSpace "$mybusiness_FreeSpace" -CloseApps "$mybusiness_ProcToClose" -AllowDeferCloseApps -DeferTimes 4
			}
			if ($mybusiness_ProcToCloseNonUI) {
				Show-InstallationWelcome -CheckDiskSpace -RequiredDiskSpace "$mybusiness_FreeSpace" -CloseApps "$mybusiness_ProcToCloseNonUI" -Silent
			}
			if ($mybusiness_ProcToBlock) {
				Show-InstallationWelcome -CloseApps "$mybusiness_ProcToBlock" -AllowDeferCloseApps -DeferTimes 4 -BlockExecution
			}
		}

        ## <Perform Pre-Uninstallation tasks here>


		#*====================================PRE-UNINSTALLATION END==================================================================
	#endregion PRE-UNINSTALLATION

	#region MAIN-UNINSTALLATION
        [String]$installPhase = 'Uninstallation'
		#*====================================MAIN-UNINSTALLATION BEGIN===============================================================

		# user dialogs (deprecated)
		if ($mybusiness_UseDialogs){
			## Only use for longer installations (Installation duration approx. >3 minutes)
			Show-InstallationProgress -WindowLocation 'BottomRight'
		}
		
	   Write-Log -Message 'Start Uninstallation OBS Studio' -Severity 2 -Source $deployAppScriptFriendlyName
	   
		Execute-Process -Path "C:\Program Files\obs-studio\uninstall.exe" -Parameters '/S' -WindowStyle Hidden

	   Write-Log -Message 'Uninstallation of OBS Studio is successful.' -Severity 2 -Source $deployAppScriptFriendlyName

		#*====================================MAIN-UNINSTALLATION END==================================================================
	#endregion MAIN-UNINSTALLATION

	#region POST-UNINSTALLATION
        [String]$installPhase = 'Post-Uninstallation'
		
		#*====================================POST-UNINSTALLATION BEGIN===============================================================	
		
		# user dialogs (deprecated)
		if ($mybusiness_UseDialogs){
			## Only use for longer installations (Installation duration approx. >3 minutes)
			Show-InstallationProgress -WindowLocation 'BottomRight'
		}
		
		## Cleanup OBS Studio Program Files Directory (If Present)
        If (Test-Path -Path "$envProgramFiles\obs-studio\") {
        Write-Log -Message "Cleanup OBS Studio Program Files Directory."
        Remove-Item -Path "$envProgramFiles\obs-studio\" -Force -Recurse -ErrorAction SilentlyContinue 
        }
        ## Cleanup OBS Studio Program Files (x86) Directory (If Present)
        If (Test-Path -Path "$envProgramFilesX86\obs-studio\") {
        Write-Log -Message "Cleanup OBS Studio Program Files (x86) Directory."
        Remove-Item -Path "$envProgramFilesX86\obs-studio\" -Force -Recurse -ErrorAction SilentlyContinue 
        }
        ## Remove OBS Studio Desktop Shortcut (If Present)
        If (Test-Path -Path "$envCommonDesktop\OBS Studio.lnk") {
        Write-Log -Message "Removing OBS Studio Desktop Shortcut."
        Remove-Item -Path "$envCommonDesktop\OBS Studio.lnk" -Force -Recurse -ErrorAction SilentlyContinue 
        }
        ## Remove OBS Studio Start Menu Shortcuts (If Present)
        If (Test-Path -Path "$envAllUsersProfile\Microsoft\Windows\Start Menu\Programs\OBS Studio*") {
        Write-Log -Message "Removing OBS Studio Start Menu Shortcuts."
        Remove-Item -Path "$envAllUsersProfile\Microsoft\Windows\Start Menu\Programs\OBS Studio*" -Force -Recurse -ErrorAction SilentlyContinue 
        }
		
        ##Removing Branding Key
		Remove-Branding

		#*====================================POST-UNINSTALLATION END=================================================================
	#endregion POST-UNINSTALLATION

#endregion UNINSTALLATION

#region REPAIR
    } ElseIf ($deploymentType -ieq 'Repair') {

	#region PRE-REPAIR
	
        [String]$installPhase = 'Pre-Repair'

        # check for pending reboot and stop script execution on true with exit code 1641, if not running in task sequence.
		if ($mybusiness_CheckForReboot){
			Set-Reboot -ForceExitScript -OnlyOnPendingReboot -MandatoryDeviceRestart
		}

		# user dialogs (deprecated)
		if ($mybusiness_UseDialogs){
			if ($mybusiness_AllowDefer){
				Show-InstallationWelcome -AllowDefer -DeferTimes 4
			}
			if ($mybusiness_ProcToClose) {
				Show-InstallationWelcome -CheckDiskSpace -RequiredDiskSpace "$mybusiness_FreeSpace" -CloseApps "$mybusiness_ProcToClose" -AllowDeferCloseApps -DeferTimes 4
			}
			if ($mybusiness_ProcToCloseNonUI) {
				Show-InstallationWelcome -CheckDiskSpace -RequiredDiskSpace "$mybusiness_FreeSpace" -CloseApps "$mybusiness_ProcToCloseNonUI" -Silent
			}
			if ($mybusiness_ProcToBlock) {
				Show-InstallationWelcome -CloseApps "$mybusiness_ProcToBlock" -AllowDeferCloseApps -DeferTimes 4 -BlockExecution
			}
		}

        ## <Perform Pre-Repair tasks here>
		
		#*====================================PRE-REPAIR END=============================================================
	#endregion PRE-REPAIR

	#region MAIN-REPAIR
        [String]$installPhase = 'Repair'
		
		#*====================================MAIN-REPAIR BEGIN===============================================================
		
        # user dialogs (deprecated)
		if ($mybusiness_UseDialogs){
			## Only use for longer installations (Installation duration approx. >3 minutes)
			#Show-InstallationProgress -WindowLocation 'BottomRight'
		}
		
        ## <Perform Repair tasks here>

		#*====================================MAIN-REPAIR END=================================================================
	#endregion MAIN-REPAIR

	#region POST-REPAIR
        [String]$installPhase = 'Post-Repair'

        ## <Perform Post-Repair tasks here>

		#*====================================POST-REPAIR BEGIN===============================================================


		#Set-Reboot

		#*====================================POST-REPAIR END=================================================================
	#endregion POST-REPAIR

#endregion REPAIR

##endregion ScriptBody
	}

    ## 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
}

Looking at your code, you are correctly checking if the process obs64 is running (held in $mybusiness_GetProcess ), but as you have modified the original Deploy-Application quite considerably, it wouldn’t be that easy to change to use my method.
I notice your if ($mybusiness_UseDialogs){ section will trigger Show-InstallationWelcome with the various different options you have configured, but it will do this for each subsequent if statement
Below this line:

			# user dialogs (deprecated)
			if ($mybusiness_UseDialogs){
			...

So if you have $mybusiness_AllowDefer and $mybusiness_ProcToClose defined (which you do) it will display the Show-InstallationWelcome dialog multiple times

quick question if #user dialogs (deprecated) are deprecated, why is this still in use?

IMHO your Deploy-Application.ps1 seems over complicated for seemingly no good reason.
Personally I think comparing a fresh copy of the Deploy-Application.ps1 from the latest PSADT zip file download (v3.9.3) with yours (I personally use Beyond Compare (Scooter Software | Home of Beyond Compare) for this type of comparison - it will allow you to show line by line, file by file and folder by folder differences, it’s great for copying or correcting code blocks between multiple scripts.

This would highlight what changes have been made and may trigger thoughts of: do I need that section / why is that there? / what does that do?
This could help answer your own questions

Thank you Adrian, i’ve tried to release a software, and the job has been completely correctly.

Thank you again

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.