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!


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

    • 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 = @(
    Get-ChildItem $UninstallKeys |
        Where-Object{$_.GetValue('DisplayName') -in $productNames} |
            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!


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


    Thursday, November 28, 2019 1:40 AM