Skip to content

Uninstall does not work #32

@o-l-a-v

Description

@o-l-a-v

The uninstaller does not remove "Checksums" from right click -> properties, so I guess the DLL is left, and still registered.

  • C:\Windows\System32\ShellExt\HashCheck.dll still exists.

Fix:

  1. Kill explorer.exe
  2. Unregister DLL: regsvr32.exe /u "C:\Windows\System32\ShellExt\HashCheck.dll" /s
  3. Delete DLL
  4. Start explorer.exe

Wrote a PowerShell script:

Click to expand
<#
    .NOTES
        Author:   Olav Rønnestad Birkeland | github.com/o-l-a-v
        Created:  2025-07-03
        Modified: 2025-07-03

        Resources:
        * 2025-07-03 <https://github.com/idrassi/HashCheck/issues/32>

    .EXAMPLE
        # Run -WhatIf
        & $psEditor.GetEditorContext().CurrentFile.Path -WhatIf

    .EXAMPLE
        # Run as administrator using gsudo
        gsudo ('& "{0}"' -f $psEditor.GetEditorContext().CurrentFile.Path)
#>


# Input and expected output
[CmdletBinding(SupportsShouldProcess)]
[OutputType([System.Void])]
Param()


# PowerShell preferences
$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'


# Assets
$PathToDll = [string] [System.IO.Path]::Combine($env:windir, 'System32', 'ShellExt', 'HashCheck.dll')
$PathToExplorer = [string] [System.IO.Path]::Combine($env:windir, 'explorer.exe')


# Failproof
## Exit if no leftovers
if (-not [System.IO.File]::Exists($PathToDll)) {
    Write-Information -MessageData ('"{0}" does not exist, nothing to clean up.' -f $PathToDll)
    Exit 0
}

## Must run as administrator if not -WhatIf
if (
    -not $PSBoundParameters.ContainsKey('WhatIf') -and
    -not (
        [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
    ).IsInRole(
        [Security.Principal.WindowsBuiltInRole]::Administrator
    )
) {
    Throw 'Scipt must be run as administrator unless -WhatIf.'
}


# Unregister and delete DLL
Try {
    # Stop explorer.exe
    if ($PSCmdlet.ShouldProcess($PathToExplorer, 'stop process')) {
        Write-Information -MessageData ('Stop process "{0}".' -f $PathToExplorer)
        $null = Stop-Process -Name 'explorer' -Force
    }
    # Unregister DLL
    if ($PSCmdlet.ShouldProcess($PathToDll, 'unregister')) {
        Write-Information -MessageData ('Unregister "{0}".' -f $PathToDll)
        cmd /c ('regsvr32.exe /u "{0}" /s' -f $PathToDll)
    }
    # Delete DLL
    if ($PSCmdlet.ShouldProcess($PathToDll, 'delete')) {
        Write-Information -MessageData ('Delete "{0}".' -f $PathToDll)
        $null = [System.IO.File]::Delete($PathToDll)
    }
}
Catch {
    Write-Error -ErrorAction 'Continue' -Exception $_.'Exception' -Message $_.'Exception'.'Message'
}
Finally {
    # Start explorer if not running
    if (
        -not $(Try{$null = Get-Process -Name 'explorer' 2>$null; $?}Catch{$false}) -and
        $PSCmdlet.ShouldProcess($PathToExplorer, 'start process')
    ) {
        Write-Information -MessageData ('Start process "{0}".' -f $PathToExplorer)
        $null = Start-Process -FilePath $PathToExplorer
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions