Uninstall Silverlight OutOfBrowser Applications

When faced with having to manually remove a Silverlight application which was installed 'Out of Browser' it can be difficult to locate the exact installation within the Users' Local Application Data folder.

A Silverlight out of browser installation is given a unique identifier which is used to create an application installation directory, this unique identifier is stored in an index file for the host.

Option 1 - Index File for each Host

As mentioned the unique appplicaton <>. From there we can locate the specific

Option 2 - Metadata File for each Installation

PowerShell Solution (using Option 1)

The most effective way I have found to resolve the issue was to use option one to find the exact installation from the out of browser index file. Knowing this I developed a PowerShell script below to locate a specific installation based on the install URL (set as $url).

$slIndex = Join-Path -ChildPath '..\LocalLow\Microsoft\Silverlight\OutOfBrowser\index' -Path $env:APPDATA -Resolve
$url = 'http://localhost:6918/GetFile.ashx?FileName=Client.xap'
$domain = ([System.Uri] $url)

$slFile = Join-Path -ChildPath $domain.Host -Path $slIndex -Resolve

$slProgram = Join-Path -ChildPath 'Microsoft Silverlight' -Path $env:ProgramFiles -Resolve

$content = Get-Content $slFile

foreach ($line in $content) {
    $fields = $line.Split("`t").Replace("`0", "")

    if ($fields.Count -gt 1) {
        $normalized = $fields[1]
        $installedFrom = ([System.Uri] $normalized)

        if ($installedFrom.Authority -eq $domain.Authority -and $installedFrom.AbsolutePath -eq $domain.AbsolutePath) {
            $origin = '/origin:"' + $installedFrom.OriginalString + '"'
            Start-Process -FilePath sllauncher.exe -ArgumentList ('/uninstall', $origin) -WorkingDirectory $slProgram
        }
    }
}