Installation failed because of a "BlockExecution" file, where a folder is expected

Hi,

I just ran into a problem where another PSAppDeployment installation left a file named ‘BlockExecution’ at the location C:\Windows\Temp\PSAppDeployToolkit.

The presence of this file prevented the creation of a folder with the same name, causing the entire installation to fail.

I solved this in the Deploy-Application.ps1, by adding a few lines:

if(Test-Path -Path "$env:temp\PSAppDeployToolkit\BlockExecution"){
    $Temp = Get-Item -Path "$env:temp\PSAppDeployToolkit\BlockExecution"
    If(!($Temp.PSIsContainer)){
        Remove-Item -Path "$env:temp\PSAppDeployToolkit\BlockExecution" -Force
    }    
}

Maybe not the prettiest solution, but for now it works.

Maybe the main file needs to check if there’s a file present there with that name, if the creation of that folder fails, before trying to elevate.

Just wanted to drop this here, since I spent quite a bit of time figuring out what was causing the installation ot fail.

Kind regards,

Joël.

You can also use -PathType parameter that specifies the type of the item. Leaf is a file/item. Container is a Directory/Folder/Container

if (Test-Path -Path "$env:temp\PSAppDeployToolkit\BlockExecution" -PathType Leaf){
    Remove-Item -Path "$env:temp\PSAppDeployToolkit\BlockExecution" -Force   
}

Thanks you for the suggestion, maybe I’ll do that next time.

One question that keeps bugging me is: How is it possible for the Toolkit to leave behind a file like that, and can this be prevented?

What version of the toolkit are we talking about?

I was using version 3.8.4.

That file is not supposed to be there. It is a bug from old versions. Theres even a command in new version of Block-AppExecution that deletes this file.