Uninstalling all versions of Quicktime using SCCM
Since QuickTime is no longer supported, I need to uninstall all versions of QuickTime on machines in my company using SCCM. So far I have created a device collection of all machines with QuickTime using a query which is working. I found a .bat script to uninstall the software which also looks good. The problem I am running into is with the detection method. I don't need to verify the presence of the application. I need to verify the Quick time folder is Not present so I know the uninstall worked and the machine is compliant. Right now my results are all coming back already complaint. How do I make a detection method that finds out is a file folder is Not present?
This is the Quicktime uninstall script I used.
@ECHO OFF
cls
TITLE Uninstalling Quicktime . . .
wmic product where "name like 'QuickTime%%'" call uninstall /nointeractive
exit /B 0
I tried this detection method but its not working.
$path = Get-ChildItem -Path C:\Program Files (x86)\QuickTime -ErrorAction SilentlyContinue
if ($path -ne $null) {
if((Test-Path -Path $path))
{
}
else
{
Write-Host "Installed"
}
} else {
Write-Host "Installed"
}
Any help would be greatly appreciated.
Thanks
Answers (2)
https://www.google.com/search?q=if+then+directory+exists&ie=utf-8&oe=utf-8#q=if+then+directory+exists+windows+batch
This is how I removed it in my environment. I am going off memory, so I don't remember what the exact name is of the QuickTime executable. Regardless, I'm sure you get the idea.
--------
$ErrorActionPreference = 'SilentlyContinue'
$QT32 = Test-Path "C:\Program Files (x86)\QuickTime\quicktime.exe"
$QT64 = Test-Path "C:\Program Files\QuickTime\quicktime.exe"
If ($QT32 -or $QT64) {}
Else {Write-Host "Uninstalled"}
--------
I was taught to think of this as a "reverse detection method." Generally you want the file to exist, but not in this case as you are looking to remove the software. So you need to only exit the application once the file no longer exists.
Script works this way ...
If statement: Hey workstation do you have QuickTime installed in $QT32 or $QT64? If you do, run my uninstall script.
Else statement: So workstation you don't have the file after running my script? Awesome, tell SCCM that the installation is complete.
I hope this makes sense, because it took me a good amount of time to finally grasp this concept. I will tell you this though, this little example has helped me remove tons and tons of unsupported software (Adobe, QuickTime, iTunes, etc.)
-Bert
Comments:
-
That's a great idea. I'm going to try it Monday and post the results.
Thanks Bert! - Thumper7181 8 years ago