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
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:
Make use of the Wait-Process command rather than a while loop to wait for the Uninstall process to finish.
Use a variable for the UninstallPath. This makes it much easier to update your code and helps avoid typos.
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"