none
Uninstall .exe with Powershell RRS feed

  • Question

  • Hello All,

    I am trying to uninstall Softros LAN messenger fro a batch of systems and want to do it via PS if possible.

    So far it has not proven possible :)

    I have been working a couple of scripts, this final rendition runs without error, but doesn't uninstall the software.

    Does anyone have any ideas as to what I am missing?

    Thank you, code below.

    Best Regards!

    Sozo

    $productNames = @("softros lan messenger")
    $UninstallKeys = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
                        'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall',
                        'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
                        )
    $results = foreach ($key in (Get-ChildItem $UninstallKeys) ) {
    
        foreach ($product in $productNames) {
            if ($key.GetValue("DisplayName") -match "$product") {
                [pscustomobject]@{
                    KeyName = $key.Name.split('\')[-1];
                    DisplayName = $key.GetValue("DisplayName");
                    UninstallString = $key.GetValue("UninstallString");
                   
                }
            }
        }
    }
    
    $results



    • Edited by Sozo73 Wednesday, November 27, 2019 11:35 PM
    Wednesday, November 27, 2019 9:46 PM

All replies

  • Please read the following instructions and fix you original post:

    The way to do this in PowerShell is as follows.

    $productNames = @(
        'softros lan messenger'
    )
    $UninstallKeys = @(
        'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
        'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall',
        'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
    )
    Get-ChildItem $UninstallKeys |
        Where-Object{$_.GetValue('DisplayName') -in $productNames} |
        ForEach-Object{
            Write-Host "$_"
            Invoke-Expression $_.GetValue('UninstallString')
        }

    \_(ツ)_/

    Wednesday, November 27, 2019 10:25 PM
  • Please fix your original post and format your code correctly. If you want people to help you, you need to make it possible for you code examples to be correctly copied.

    Posting code that cannot be run or easily edited is no help to anyone.


    \_(ツ)_/

    Wednesday, November 27, 2019 11:13 PM
  • Corrected, thank you jrv!
    Wednesday, November 27, 2019 11:35 PM
  • Than you. That is much better.

    Delete your second post as it is not of much use.


    \_(ツ)_/

    Wednesday, November 27, 2019 11:57 PM
  • So, tried the code suggestion, but it returns the same as mine, meaning that it runs fine and completes but does not uninstall the software.

    Any takers? 

    Thank you for any assists!

    Sozo

    Thursday, November 28, 2019 1:28 AM
  • What is the output? You have to provide complete information.


    \_(ツ)_/

    Thursday, November 28, 2019 1:40 AM