Uninstall exe applications from Windows devices.
  • 14 Mar 2024
  • 2 Minutes to read
  • PDF

Uninstall exe applications from Windows devices.

  • PDF

Article summary

The following PowerShell script helps the IT Admins to uninstall Exe application(s) from their managed Windows devices.

  1. Create a file on your desktop, for example, uninstall_exe.ps1 and open it in a text editor like notepad++

  2. Copy the contents below to the file or click here to download the file.

    # Define the path to the application executable
    $applicationPath = "C:\Path\To\Application.exe"
    
    # Define the path to the uninstaller
    $uninstallerPath = "C:\Path\To\Uninstaller.exe"
    
    # Define any additional uninstallation arguments if needed
    $uninstallArguments = "/S"  # Silent uninstallation argument
    
    # Check if the application is installed
    if (Test-Path $applicationPath) {
        # Uninstall the application
        Start-Process -FilePath $uninstallerPath -ArgumentList $uninstallArguments -Wait
        Write-Output "Application has been uninstalled successfully."
    } else {
        Write-Output "Application is not installed on this system."
    }
  3. In the Script,

    1. Replace $applicationPath with the path to the application's executable file.

    2. Replace $uninstallerPath with the path to the application's uninstaller executable file (if available). If the application doesn't have a separate uninstaller, you may need to find an alternative method to uninstall it.

    3. Modify $uninstallArguments as needed to pass any additional arguments required for silent uninstallation.

  4. Ensure that the paths and arguments provided in the script match the installation and uninstallation process of the specific application you want to uninstall.

  5. Follow our guide to upload & publish the PowerShell script using Scalefusion Dashboard.

  6. Once the script is successfully executed, you will be able to see the status of the same in the View Status report on the Scalefusion dashboard.

For example, the following script helps to uninstall WinRar application.

# This is a script tested for just the WinRar application. Define the path to the WinRAR executable. 

$winrarPath = "C:\Program Files\WinRAR\WinRAR.exe"

# Check if WinRAR is installed
if (Test-Path $winrarPath) {
    # Uninstall WinRAR
    Start-Process -FilePath "C:\Program Files\WinRAR\Uninstall.exe" -ArgumentList "/S" -Wait
    Write-Output "WinRAR has been uninstalled successfully."
} else {
    Write-Output "WinRAR is not installed on this system."
}

Please note that to use the PowerShell scripts, the Scalefusion MDM Agent Application must be installed on the device(s). Please follow our guide to publish and install the Scalefusion MDM Agent Application.

Notes:

  1. The scripts and their contents are sourced from various albeit authenticated Microsoft sources and forums.

  2. Please validate the scripts on a test machine before deploying them on all your managed devices.

  3. Scalefusion has tested these scripts, however, Scalefusion will not be responsible for any loss of data or system malfunction that may arise due to the incorrect usage of these scripts.


Was this article helpful?