Skip to content

Instantly share code, notes, and snippets.

@pdolinic
Forked from mgeeky/Cleanup-ClickOnce.ps1
Created June 27, 2023 16:33
Show Gist options
  • Select an option

  • Save pdolinic/3c42c398245e0ba1da2907c7b76d1b7d to your computer and use it in GitHub Desktop.

Select an option

Save pdolinic/3c42c398245e0ba1da2907c7b76d1b7d to your computer and use it in GitHub Desktop.

Revisions

  1. @mgeeky mgeeky revised this gist Jun 27, 2023. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Cleanup-ClickOnce.ps1
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,10 @@
    # PS> . .\Cleanup-ClickOnce.ps1
    # PS> Cleanup-ClickOnce -Name MyAppName
    #
    # Other than that you might also try using these commands:
    # PS> rundll32 dfshim.dll,ShArpMaintain C:\Path\To\ClickOnce.application
    # PS> rundll32 dfshim.dll CleanOnlineAppCache
    #

    function Cleanup-ClickOnce($Name) {
    if ($Name.Length -gt 6) {
  2. @mgeeky mgeeky revised this gist Jun 27, 2023. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions Cleanup-ClickOnce.ps1
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,6 @@
    #

    function Cleanup-ClickOnce($Name) {

    if ($Name.Length -gt 6) {
    $Name = $Name.Substring(0, 4) + "\."
    }
    @@ -18,8 +17,6 @@ function Cleanup-ClickOnce($Name) {
    If ($_ -match $rex) {
    Write-Host "[+] Cleaning: $($_.Name)" -ForegroundColor Green
    Remove-Item -Force -Recurse "Registry::$_" -EA SilentlyContinue | Out-Null


    }
    }

  3. @mgeeky mgeeky created this gist Jun 27, 2023.
    41 changes: 41 additions & 0 deletions Cleanup-ClickOnce.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    #
    # Usage:
    # PS> . .\Cleanup-ClickOnce.ps1
    # PS> Cleanup-ClickOnce -Name MyAppName
    #

    function Cleanup-ClickOnce($Name) {

    if ($Name.Length -gt 6) {
    $Name = $Name.Substring(0, 4) + "\."
    }

    $rex = $Name + "\..+"

    Write-Host "`nCleaning ClickOnce leftovers: $rex `n" -ForegroundColor Yellow

    Get-ChildItem -Recurse "HKCU:\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\SideBySide\2.0" -EA SilentlyContinue | ForEach-Object {
    If ($_ -match $rex) {
    Write-Host "[+] Cleaning: $($_.Name)" -ForegroundColor Green
    Remove-Item -Force -Recurse "Registry::$_" -EA SilentlyContinue | Out-Null


    }
    }

    $Paths = @(
    "$env:Localappdata\Apps\2.0"
    "$env:Localappdata\Deployment"
    "$env:Localappdata\Microsoft\Windows\INetCache\IE"
    "$env:Temp\Deployment"
    )

    foreach ($Path in $Paths) {
    Get-ChildItem -Recurse $Path | ForEach-Object {
    If ($_ -match $rex) {
    Write-Host "[+] Cleaning: $($_.FullName)" -ForegroundColor Green
    Remove-Item -Force -Recurse $_.FullName
    }
    }
    }
    }