This project is read-only.

Block-AppExecution function....

Topics: Archive - Toolkit Extensions
Sep 28, 2014 at 1:41 PM
Hi all

For better user experience, I display the popup "Show-InstallationWelcome" only if there is a process launched.....
If the process not launch, toolkit blocks the process until the install be finished....

I known it's not recommended but this is the only way I found to reduce popup to users !

Here is the code :
If ($deploymentType -ne "uninstall") { $installPhase = "Pre-Installation"

    # =========================================================
    # If proccess open = Show-InstallationWelcome
    # If proccess NOT open = Block-AppExecution 
    # =========================================================

    if (Get-Process -Name ProcessName1,ProcessName2,ProcessName3 -ErrorAction SilentlyContinue)
        Show-InstallationWelcome -CloseApps "ProcessName1,ProcessName2,ProcessName3"  -BlockExecution -AllowDefer -DeferTimes "20" -CheckDiskSpace -PersistPrompt

    Block-AppExecution -ProcessName ProcessName1,ProcessName2,ProcessName3

    # =========================================================
    # Install
    # =========================================================


    # =========================================================
    # Unblock 
    # =========================================================

$installPhase = "Post-Installation"
it works great only if the command line that blocks applications does not exceed 261 characters :

[Pre-Installation] Executing [C:\WINDOWS\System32\schtasks.exe /Create /TN Manufacturer001_Application01_10.0_EN__BlockedApps /RU System /SC ONSTART /TR "powershell.exe -ExecutionPolicy Bypass -NoProfile -WindowStyle Hidden -File 'C:\Users\Public\PSAppDeployToolkit\AppDeployToolkitMain.ps1' -CleanupBlockedApps -InstallTitle 'Manufacturer001 Application01 10.0' -InstallName 'Manufacturer001_Application01_10.0_EN_'"]

[Pre-Installation] Standard error output from the process []: Error: The value for the option '/ TR' can not contain more than 261 characters.

Do you think it's possible :
  • Block applications if the proccess are not launched ?
or how to have a evolution of this function ?

Thanks a lot
Sep 28, 2014 at 9:32 PM
Have you tried using this parameter:

.PARAMETER AllowDeferCloseApps
Enables an optional defer button to allow the user to defer the installation only if there are
 running applications that need to be closed.
Sep 29, 2014 at 3:05 PM
Edited Sep 29, 2014 at 3:05 PM

I'll have to look at the documentation more carefully.... Sorry :-(

We use this command line but we had the same issue.

Show-InstallationWelcome -CloseApps "notepad" -BlockExecution -AllowDeferCloseApps -DeferTimes "20" -CheckDiskSpace -PersistPrompt

it seems that schtasks.exe can not create a task with more than 261 characters....
Oct 20, 2014 at 9:41 PM
Thanks for flagging the schtasks issue, we've got it on our list to fix.