Answered by:
Uninstalled a program via PowerShell script, but it still shows up in Programs and Features

Question
-
I wrote a script that uninstalls a program just fine, but it still shows up in Programs and Features due to its entries still existing in the Registry.
Here is a portion of my script:
Start-Process -FilePath MsiExec -ArgumentList "/X$($MyProgram.ProdID)", '/quiet' -NoNewWindow -Wait -PassThru
I believe the reason it is still showing up in Programs and Features is because I am missing some MsiExec switch to instruct it to be removed. I vaguely recall dealing with this about two years ago and I wrote a script that did exactly this, but now I completely forgot what it was.
Can someone help me out here, please?
Thank you
- Edited by I AM Sir Ask Alot Saturday, January 10, 2015 2:16 AM
- Moved by Bill_Stewart Monday, May 18, 2015 5:02 PM Question outside forum scope
Saturday, January 10, 2015 1:47 AM
Answers
-
Post inthe Microsoft forum for SCCM. THe script is SCCM specific and your question is about product configuraiton and not about scripting.
If it is ForeFront thenyou are correct. Forefront supports the REMOVEDATA property. Post in Forefront forum for this too.
¯\_(ツ)_/¯
Saturday, January 10, 2015 7:01 AM
All replies
-
The unistall is completely under the control of the author of the uninstall/install package:
Windows ® Installer. V 5.0.9600.17415 msiexec /Option <Required Parameter> [Optional Parameter] Install Options </package | /i> <Product.msi> Installs or configures a product /a <Product.msi> Administrative install - Installs a product on the network /j<u|m> <Product.msi> [/t <Transform List>] [/g <Language ID>] Advertises a product - m to all users, u to current user </uninstall | /x> <Product.msi | ProductCode> Uninstalls the product Display Options /quiet Quiet mode, no user interaction /passive Unattended mode - progress bar only /q[n|b|r|f] Sets user interface level n - No UI b - Basic UI r - Reduced UI f - Full UI (default) /help Help information Restart Options /norestart Do not restart after the installation is complete /promptrestart Prompts the user for restart if necessary /forcerestart Always restart the computer after installation Logging Options /l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile> i - Status messages w - Nonfatal warnings e - All error messages a - Start up of actions r - Action-specific records u - User requests c - Initial UI parameters m - Out-of-memory or fatal exit information o - Out-of-disk-space messages p - Terminal properties v - Verbose output x - Extra debugging information + - Append to existing log file ! - Flush each line to the log * - Log all information, except for v and x options /log <LogFile> Equivalent of /l* <LogFile> Update Options /update <Update1.msp>[;Update2.msp] Applies update(s) /uninstall <PatchCodeGuid>[;Update2.msp] /package <Product.msi | ProductCode> Remove update(s) for a product Repair Options /f[p|e|c|m|s|o|d|a|u|v] <Product.msi | ProductCode> Repairs a product p - only if file is missing o - if file is missing or an older version is installed (default) e - if file is missing or an equal or older version is installed d - if file is missing or a different version is installed c - if file is missing or checksum does not match the calculated value a - forces all files to be reinstalled u - all required user-specific registry entries (default) m - all required computer-specific registry entries (default) s - all existing shortcuts (default) v - runs from source and recaches local package Setting Public Properties [PROPERTY=PropertyValue] Consult the Windows ® Installer SDK for additional documentation on the command line syntax. Copyright © Microsoft Corporation. All rights reserved. Portions of this software are based in part on the work of the Independent JPEG Group.
¯\_(ツ)_/¯
Saturday, January 10, 2015 4:27 AM -
Thanks for responding.
Okay so if the uninstall is not also clearing out the Registry entries, should I perform a Remove-Item to delete that?
Isn't there a REMOVEDATA=1 MSI switch as well?
Saturday, January 10, 2015 6:23 AM -
Thanks for responding.
Okay so if the uninstall is not also clearing out the Registry entries, should I perform a Remove-Item to delete that?
Isn't there a REMOVEDATA=1 MSI switch as well?
Only if the author of the MSI has implemented it.
Shortcuts created by users or other means cannot be removed via an MSI uninstall. For detailss on what is available you need to contact the vendor. Shortcuts are not considered data and are not in the registry. They ar ein the file system in most cases.
You can also dump the MSI dayabase to see what bits it contains. THe tool for this is in the MS download center I believe. You can also use the tool to customize the MSI.
¯\_(ツ)_/¯
- Edited by jrv Saturday, January 10, 2015 6:39 AM
Saturday, January 10, 2015 6:37 AM -
Ok I see.
You mean a tool like Orca or Super Orca?
Thanks again
Saturday, January 10, 2015 6:40 AM -
You should also realize that none of your questions have anything to do with scripting. THey should all be directed to the authir or vendor of the product.
¯\_(ツ)_/¯
Saturday, January 10, 2015 6:41 AM -
I realize that, but honestly don't know where else to submit a question like this in the forums? Also, the vendor is Microsoft. What I am trying to uninstall is any Forefront component, because when I deployed the SCEP client via SCCM 2012 the SCEP client was not able to uninstall some of the Forefront components.
Here is my script:
$NewLine = "`r`n" $NewLine Write-Output "Please wait ..." #region ---------- Declare WMI Variables to be Used ---------- $CM12R2ClientInstalled = Get-WmiObject -Class Win32_Product | Where-Object -FilterScript { $_.Name -eq "Configuration Manager Client" -and $_.Version -ge "5.00.7958.1000" } $FCSInstalled = Get-WmiObject -Class Win32Reg_AddRemovePrograms | Where-Object -FilterScript { $_.DisplayName -match "Forefront" } $SCEPInstalled = Get-WmiObject -Class Win32Reg_AddRemovePrograms | Where-Object -FilterScript { $_.DisplayName -eq "System Center Endpoint Protection" } #endregion ---------- Declare Variables to be Used ---------- #region --------- Check if the SCCM 2012 R2 Client is Installed --------- $CM12ClientService = Get-Service -Name CcmExec If (($CM12R2ClientInstalled -ne $null) -and ($CM12ClientService -ne $null)) { $NewLine Write-Output "The $($CM12R2ClientInstalled.Name) $($CM12R2ClientInstalled.Version) is installed on $($env:COMPUTERNAME)" #endregion --------- Check if the SCCM 2012 R2 Client is Installed --------- #region -------- Uninstall any Forefront Component if any are Installed --------- If ($FCSInstalled) { $NewLine Write-Output "The following Forefront component(s) are installed on $($env:COMPUTERNAME):" $NewLine $FCSInstalled.DisplayName Foreach ($FCS in $FCSInstalled) { $NewLine Write-Output "Preparing to uninstall $($FCS.DisplayName)" $UninstallFCS = Start-Process -FilePath MsiExec -ArgumentList "/X$($FCS.ProdID)", 'REMOVEDATA=1' -NoNewWindow -Wait -PassThru If ($($UninstallFCS.ExitCode) -eq '0') { $NewLine Write-Output "$($FCS.DisplayName) uninstalled successfully!" $NewLine #endregion -------- Uninstall any Forefront Component if any are Installed --------- #region --------- Install the SCEP Client if it is Not Installed ---------- If ($SCEPInstalled -eq $null) { $NewLine Write-Output "The System Center Endpoint Protection client is not installed on $($env:COMPUTERNAME)" $InstallSCEP = Start-Process -FilePath "C:\Windows\ccmsetup\SCEPInstall.exe" -ArgumentList '/s', '/q', '/NoSigsUpdateAtInitialExp', '/policy "C:\Windows\CCM\EPAMPolicy.xml"' -NoNewWindow -Wait -PassThru If ($($InstallSCEP.ExitCode) -eq '0') { $NewLine Write-Output "System Center Endpoint Protection installed successfully!" $NewLine } Else { $NewLine Write-Warning -Message "System Center Endpoint Protection failed to install on $($env:COMPUTERNAME) with exit error: $($InstallSCEP.ExitCode)" $NewLine } } #endregion --------- Install the SCEP Client if it is Not Installed ---------- Else { $NewLine Write-Output "The System Center Endpoint Protection client is already installed on $($env:COMPUTERNAME)!" $NewLine } } Else { $NewLine Write-Warning -Message "$($FCS.DisplayName) failed to uninstall on $($env:COMPUTERNAME) with exit error: $($UninstallFCS.ExitCode)" $NewLine } } } Else { $NewLine Write-Output "No Forefront components are installed on $($env:COMPUTERNAME)!" #region ---------- Install the SCEP Client if it is NOT Installed ---------- If ($SCEPInstalled -eq $null) { $NewLine Write-Output "The System Center Endpoint Protection client is not installed on $($env:COMPUTERNAME)" $InstallSCEP = Start-Process -FilePath "C:\Windows\ccmsetup\SCEPInstall.exe" -ArgumentList '/s', '/q', '/NoSigsUpdateAtInitialExp', '/policy "C:\Windows\CCM\EPAMPolicy.xml"' -NoNewWindow -Wait -PassThru If ($($InstallSCEP.ExitCode) -eq '0') { $NewLine Write-Output "System Center Endpoint Protection installed successfully!" $NewLine } Else { $NewLine Write-Warning -Message "System Center Endpoint Protection failed to install on $($env:COMPUTERNAME) with exit error: $($InstallSCEP.ExitCode)" $NewLine } } #endregion --------- Install the SCEP Client if it is Not Installed ---------- Else { $NewLine Write-Output "The System Center Endpoint Protection client is already installed on $($env:COMPUTERNAME)!" $NewLine } } } Else { $NewLine Write-Output "The System Center Configuration Manager 2012 R2 client is not installed on $($env:COMPUTERNAME)!" $NewLine }
- Edited by I AM Sir Ask Alot Saturday, January 10, 2015 6:56 AM
Saturday, January 10, 2015 6:53 AM -
Post inthe Microsoft forum for SCCM. THe script is SCCM specific and your question is about product configuraiton and not about scripting.
If it is ForeFront thenyou are correct. Forefront supports the REMOVEDATA property. Post in Forefront forum for this too.
¯\_(ツ)_/¯
Saturday, January 10, 2015 7:01 AM -
Will do, thanksSaturday, January 10, 2015 7:03 AM
-
Will do, thanks
I have done configuration amnagement on many systems from mainframes to minis and even factory controllers for years. I have always tried to use all vendor resources about a productt to understand how to manage the product. Before the Internet this usually meant spending a long telephone call or two to support to get the info.
Themethod seems to still be the best approach to problem solving. It is easier now due to forrums and the Internet. Scripting is really a last stop with product specific issues.
Good luck with this.
¯\_(ツ)_/¯
Saturday, January 10, 2015 7:24 AM -
Thanks again jrv, I appreciate it.Sunday, January 11, 2015 6:40 AM
-
You are welcome. Good luck with your task.
¯\_(ツ)_/¯
Sunday, January 11, 2015 7:47 AM