Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Looping an uninstall per user

Hi All,

We have an app that we're attempting to convert to install, but one of my challenges is uninstalling the old method that installed into everyone's Appdata folder.  It's one of the larger communication chat apps at the moment.

I know the command to uninstall it manually from the computer by using PDQ Inventory for an individual:

"C:\Users\%USERNAME%\AppData\Local\USERAPP\Update.exe" --uninstall -s

But I'm trying to figure out how to loop this and have never been much good on coding.  

 

Basically:

Get a list of all user profiles on the computer

Run the command through all user profiles - but don't fail if the command was unsuccessful.

I'm sure that this has been done with other software prior to me - any ideas?

1

Comments

2 comments
Date Votes
  • Mike,

    Try this:

    #Define your value of "USERAPP" here
    $userApp = "USERAPP"

    #Get a list of all user profiles on the system
    $path = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*'
    $profileList = Get-ItemProperty -Path $path | Select-Object -Property PSChildName, ProfileImagePath

    #Run the command through all user profiles
    foreach ($profile in $profileList) {
         if (Test-Path $($profile.ProfileImagePath)\AppData\Local\$userApp\Update.exe) {
              Invoke-Command "$($profile.ProfileImagePath)\AppData\Local\$userApp\Update.exe --uninstall -s"
         }
    }

    #Close script with error code 0, indicating success
    exit 0

    1
  • I'm having this same issue with the same vendor's product it sounds like. Was this ever confirmed to work? Was this run as PowerShell?

    0