Forum Discussion

oryxway's avatar
oryxway
Iron Contributor
Oct 23, 2024

Uninstall with system account

I am trying to uninstall a software and it is specified that the 

Install behavior to be  System
 
I am not able to uninstall the software through PowerShell. When I run the PowerShell script locally it prompts me enter my service account which is how we install software or uninstall software. I am not sure how we could overrule this and install or uninstall software's? I thought SYSTEM account should take care of this.
 
 

# Set execution policy to bypass
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force

# Get the uninstall string from the registry
$uninstallString = (Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{1B4AF183-7693-42EC-B7EE-B6B1FB0140F0}_is1").UninstallString

# Start the uninstallation process with administrative privileges
Start-Process -FilePath $uninstallString -ArgumentList "/SILENT" -Wait -Verb RunAs

 
 
  • Did you also tested this from the device itself when running as system? with the use of psexec -i -s powershell you could open a powershell session in the system context. From there on you could also choice to open the 32 bits version of powershell (sysnative) to find out if maybe the 32 bits issue is giving you issues finding the proper uninstall string
  • micheleariis's avatar
    micheleariis
    Steel Contributor

    oryxway Hi, 2 things:

     

    1-Can you try removing the -Verb RunAs parameter? Since you are running the script as SYSTEM account, you can remove the -Verb RunAs parameter. This should stop the script from asking for credentials.

     

    2-Verify that the $uninstallString variable contains the correct path to the uninstall executable.

    • oryxway's avatar
      oryxway
      Iron Contributor
      Thank you, I did that mistake lol removed it and I had to change this to Run script in 64 bit PowerShell Host
      Yes

Resources