Skip to content

(chocolatey-core.extension/extensions/Get-AppInstallLocation.ps1) Access Denied on Program Files directory will fail all application installs #13

Description

@waikinw

If any directory gets Access Denied (due to antivirus), the current function will fail. Antivirus does not allow directory scan for its own directory under "C:\Program Files**" - "C:\Program Files\AntivirusSoftware". This makes all packages that try to install using using this extension also fail since the app can't complete its registration.

Expected Behavior

Package/Application installs completes successfully.

Current Behavior

Package/Application installs fail when using this function.

Possible Solution

The fix below works but there may be a better method to scan dirs.

For Get-AppInstallLocation.ps1:

line 63 of Get-AppInstallLocation.ps1

Write-Verbose "Trying Program Files with 2 levels depth: $dirs"
#$dirs = $Env:ProgramFiles, "$Env:ProgramFiles\*\*"
#if (Get-ProcessorBits 64) { $dirs += ${ENV:ProgramFiles(x86)}, "${ENV:ProgramFiles(x86)}\*\*" }
#$location = (ls $dirs | ? {$_.PsIsContainer}) -match $AppNamePattern | select -First 1 | % {$_.FullName}
$dirs = @($Env:ProgramFiles)
if (Get-ProcessorBits 64) { $dirs += ${ENV:ProgramFiles(x86)}}
$location = (ls $dirs -filter '*' -depth 2 | ? {$_.PsIsContainer}) -match $AppNamePattern | select -First 1 | % {$_.FullName}

Steps to Reproduce (for bugs)

  1. Create directory under C:\Program Files\AntivirusApp
  2. Revoke all permissions to that directory to simulate "Access Denied" (such as to simulate antivirus blocking all read access)
  3. Attempt app install that uses Chocolatey Core extension -- choco install notepadplusplus

Context

Unable to install any packages using this extension

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions