简体   繁体   中英

Uninstall programs with Powershell silently

There are two programs which I need to Uninstall silently through powershell, I tried lots of scenario still nothing is working. Particularly I need to uninstall these two programs " Microsoft ASP.NET Core 3.1.16 Shared Framework (x64) " & " Microsoft ASP.NET Core 3.1.16 Shared Framework (x86) "

I am trying these commands to uninstall but it's giving other option:


    PS C:\Windows\system32> $MyApp = Get-WmiObject -Class Win32_Product | Where-Object{$_.Name -eq "Microsoft ASP.NET Core 3.1.16 Shared Framework (x64)"}
    $MyApp.Uninstall()
    
    
    __GENUS          : 2
    __CLASS          : __PARAMETERS
    __SUPERCLASS     : 
    __DYNASTY        : __PARAMETERS
    __RELPATH        : 
    __PROPERTY_COUNT : 1
    __DERIVATION     : {}
    __SERVER         : 
    __NAMESPACE      : 
    __PATH           : 
    ReturnValue      : 0
    PSComputerName   : 

Return value is 0 still it's not uninstalling anything.

Please let me know what I am doing wrong.

You can run the following PowerShell code to get the UninstallString for the products from the registry:

Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object { $_.DisplayName -match ".NET" } | Select-Object -Property DisplayName, UninstallString
DisplayName                                          UninstallString
-----------                                          ---------------
Microsoft ASP.NET Core 3.0.3 Shared Framework (x64)  MsiExec.exe /X{04DEAACD-DD28-3F35-980F-9B3123640CA7}

Then copy the appropriate MsiExec /X{...} commands from the output and paste them into an elevated PowerShell or cmd prompt, and add /quiet to the end to make them run silently.

msiexec

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM