VLC Player Uninstall

Hi,
I’m looking to deploy VLC to our business. The Install works great, and the Uninstall works ok but this folder remains
C:\Program Files\VideoLAN
I’ve tried deleting this folder but for some reason it won’t delete

        ## Delete the Remaining VLC Folder
        Remove-Item -path "C:\Program Files\VideoLAN" -Recurse -Force -ErrorAction:SilentlyContinue

This is in the error log. Does anyone have any ideas? This is run under the system context so it should have permission to delete?

<![LOG[[Uninstallation] :: Delete folder [C:\Program Files\VideoLAN\] recursively...]LOG]!><time="10:17:52.0400" date="11-17-2022" component="Remove-Folder" context="NT AUTHORITY\SYSTEM" type="1" thread="9680" file="Deploy-Application.ps1">
<![LOG[[Uninstallation] :: The following error(s) took place while deleting folder(s) and file(s) recursively from path [C:\Program Files\VideoLAN\].
Error Record:
-------------At C:\Users\TestUser\VLC V3\AppDeployToolkit\AppDeployToolkitMain.ps1:3611 char:7
+ ...             Remove-Item -LiteralPath $Path -Force -Recurse -ErrorActi ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error Record:
-------------At C:\Users\TestUser\VLC V3\AppDeployToolkit\AppDeployToolkitMain.ps1:3611 char:7
+ ...             Remove-Item -LiteralPath $Path -Force -Recurse -ErrorActi ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error Record:
-------------At C:\Users\TestUser\VLC V3\AppDeployToolkit\AppDeployToolkitMain.ps1:3611 char:7
+ ...             Remove-Item -LiteralPath $Path -Force -Recurse -ErrorActi ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]LOG]!><time="10:17:53.3460" date="11-17-2022" component="Remove-Folder" context="NT AUTHORITY\SYSTEM" type="2" thread="9680" file="Deploy-Application.ps1">

You might have something “Sitting” on the folder like Windows Explorer opened to the that folder (or a sub-folder). Could be another app, too.

Also, you should be using PSADT’s Remove-Folder function instead.

This how i uninstalled it, hope it gives some help forward.

		    ## <Perform UNINSTALLATION tasks here>
                # den - msi - uninstall of all versions with an automatic wildcard * before and after display name
                    Remove-MSIApplications -Name 'VLC media player'

                # den - msi - extra remove
                    Execute-MSI -Action Uninstall -Path '{5C081C2A-82EE-44F4-A379-DEC9154CEE90}' -ContinueOnError:$true # 3.0.16 x32
                    Execute-MSI -Action Uninstall -Path '{1BB20266-7C52-4909-B075-22156F75D22C}' -ContinueOnError:$true # 3.0.16 x64
                    Execute-MSI -Action Uninstall -Path '{52165355-165A-4EED-8058-B0945F00ABDE}' -ContinueOnError:$true # 2.2.8 x32
                    Execute-MSI -Action Uninstall -Path '{34A66242-34A2-4049-9808-1A693370FACE}' -ContinueOnError:$true # 3.0.8 x64

                # den - remove old exe
                    if (test-path "C:\Program Files\VideoLAN\VLC") 
                        {Execute-Process -Path "$envProgramFiles\VideoLAN\VLC\uninstall.exe" -Parameters '/S' -WindowStyle 'Hidden' -ContinueOnError:$true}
                    if (test-path "C:\Program Files (x86)\VideoLAN\VLC") 
                        {Execute-Process -Path "$envProgramFilesX86\VideoLAN\VLC\uninstall.exe" -Parameters '/S' -WindowStyle 'Hidden' -ContinueOnError:$true}


                # den - remove catalog leftovers
                    if (test-path "C:\Program Files\VideoLAN") {Remove-Folder -Path "C:\Program Files\VideoLAN"}
                    if (test-path "C:\Program Files (x86)\VideoLAN") {Remove-Folder -Path "C:\Program Files (x86)\VideoLAN"}

                # den - user profile folder cleanups
                    if (test-path "C:\Users\Default\AppData\Roaming\vlc") {Remove-Folder -Path "C:\Users\Default\AppData\Roaming\vlc"}

                # den - remove folder in user profiles
                    $UserDir = "C:\Users"
                        Write-Host "$UserDir den-track" -ForegroundColor Cyan -BackgroundColor DarkGray
                    $Folders = Get-ChildItem -Path $UserDir
                        Write-Host "$Folders den-track" -ForegroundColor Yellow -BackgroundColor DarkGray
                        ForEach ($row in $Folders) 
                        {
                            if (Test-Path "$Userdir\$row\AppData\Roaming\vlc") {Remove-Folder -Path "$Userdir\$row\AppData\Roaming\vlc"}
                        }

I do it like this…

        If (Get-LoggedOnUser) {
            Show-InstallationWelcome -CloseApps "vlc" -PersistPrompt ##-BlockExecution
		}

        ## Remove MSI applications
        Write-Log -Message "Remove application." -Source $installPhase
        [psobject]$FoundSoftware = Get-InstalledApplication -Name "VLC media player"
        If ($FoundSoftware) {
            Remove-MSIApplications -Name "VLC media player*" -WildCard -ContinueOnError $true
            Start-Sleep -Seconds 5
        }

        ## Remove EXE applications
        [psobject]$FoundSoftware = Get-InstalledApplication -Name "VLC media player"
        If ($FoundSoftware) {
            Foreach ($UninstallPath in $FoundSoftware.UninstallString) {
                If ($UninstallPath.Contains('"')) {
                    $UninstallPath = [regex]::Match($UninstallPath,'"(.*?)"').Groups[1].Value
                }
                If (Test-Path -Path $UninstallPath -PathType Leaf) {
                    Execute-Process -Path $UninstallPath -Parameters "/S" -WindowStyle Hidden -ContinueOnError $true
                    Start-Sleep -Seconds 5
                } Else {
                     Write-Log -Message "Remove executable not found. [$UninstallPath]" -Severity 2 -Source $installPhase  
                }
            }
        }

            [string[]]$ProfilePaths = Get-UserProfiles | Select-Object -ExpandProperty "ProfilePath" ##-ExcludeDefaultUser $true
            ForEach($UserProfilePath in $ProfilePaths) {
                Write-Log -Message "Edit userprofile: [$UserProfilePath]" -Source $installPhase
                Remove-Folder -Path "$UserProfilePath\$AppDataRoaming\vlc"
            }
        }

There are no remaing folders…

1 Like

Hi, don’t know if you are using the MSI or EXE file to install. We always use the 64bit MSI file as it is easier to maintain.VLC latest MSI download
Regarding the folder left behind. The uninstall.exe (if exe is used to install) starts a sub process called something like un_A.exe. The script sees the uninstall end, goes on and tries to delete the folder while the uninstall is still busy with the un_?.exe. We use a little bit of code to wait on the Un_?.exe. Since the ? can be anything a wildcard is used. Yes, with two uninstalls at a time this could go wrong. But we take that risk in our environment. If you want to switch from the exe to the MSI file put the code in the ‘Pre-installation’ part of your script.
The code:

        # Stop process forced since it is a non critical application
        Stop-Process -Name VLC -ErrorAction SilentlyContinue -Force
        # REmove the x64 version if present
        if (Test-Path -Path "$envProgramFiles\VideoLan\VLC\uninstall.exe") {
            Execute-Process -Path "$envProgramFiles\VideoLan\VLC\uninstall.exe" -Parameters "/S"
            $cnt = 0
            $sec = 2
            Sleep -Seconds $sec
            while (Get-Process -Name un_?) {
                Sleep -Seconds $sec
                $cnt = $cnt + $sec
                if ($cnt -ge ($sec * 30)) {Stop-Process -Name un_? -ErrorAction SilentlyContinue -Force}
            }
            Remove-Folder -Path "$envProgramFiles\VideoLan\VLC" -ContinueOnError $True
        }
        #REmove the x86 version if present
        if (Test-Path -Path "$envProgramFilesx86\VideoLan\VLC\uninstall.exe") {
            Execute-Process -Path "$envProgramFilesx86\VideoLan\VLC\uninstall.exe" -Parameters "/S"
            $cnt = 0
            $sec = 2
            Sleep -Seconds $sec
            while (Get-Process -Name un_?) {
                Sleep -Seconds $sec
                $cnt = $cnt + $sec
                if ($cnt -ge ($sec * 30)) {Stop-Process -Name un_? -ErrorAction SilentlyContinue -Force}
            }
            Remove-Folder -Path "$envProgramFilesx86\VideoLan\VLC" -ContinueOnError $True
        }

        if (Test-Path -Path "$envCommonStartMenuPrograms\VideoLAN") {Remove-Folder -Path "$envCommonStartMenuPrograms\VideoLAN"}
        if (Test-Path -Path "$envCommonDesktop\VLC media player.lnk") {Remove-File -Path "$envCommonDesktop\VLC media player.lnk"}

@R.Robesin That code looks very similar to what we use to uninstall older versions of VLC. A few of suggestions to improve that code:

  1. Make use of the Wait-Process command rather than a while loop to wait for the Uninstall process to finish.
  2. Use a variable for the UninstallPath. This makes it much easier to update your code and helps avoid typos.
  3. No need to use Test-Path before deleting the folders/shortcuts. If the shortcuts dont exist Remove-Folder/Remove-File will simply write that to the log and the script will continue.

Make sure with VLC uninstall that you wait for the orphaned child process of “UN_A” to finish before you continue with the script. I use the lines below directly after the uninstall Execute-Process line to wait for it to finish.

Write-Log "WAIT PROCESS un_A"  -Source "COMMENT"
Wait-Process -Name "un_A"

I hope that helps.

2 Likes