Skip to content

Instantly share code, notes, and snippets.

@jbaznik
Forked from broestls/Remove_VMwareTools.ps1
Created September 23, 2025 05:06
Show Gist options
  • Save jbaznik/01bac9b7a7dbf8fac2008e35335c4b70 to your computer and use it in GitHub Desktop.
Save jbaznik/01bac9b7a7dbf8fac2008e35335c4b70 to your computer and use it in GitHub Desktop.

Revisions

  1. @broestls broestls revised this gist Dec 8, 2023. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions Remove_VMwareTools.ps1
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,7 @@ $reg_targets = @(
    )

    $VMware_Tools_Directory = "C:\Program Files\VMware"
    $VMware_Common_Directory = "C:\Program Files\Common Files\VMware"

    # Create an empty array to hold all the uninstallation targets and compose the entries into the target array
    $targets = @()
    @@ -56,6 +57,12 @@ If(Test-Path $VMware_Tools_Directory) {
    $targets += $VMware_Tools_Directory
    }

    # Thanks to @Gadgetgeek2000 for pointing out that the script leaves some 500mb of extra artifacts on disk.
    # This blob removes those.
    If(Test-Path $VMware_Common_Directory) {
    $targets += $VMware_Common_Directory
    }

    # Create a list of services to stop and remove
    $services = Get-Service -DisplayName "VMware*"
    $services += Get-Service -DisplayName "GISvc"
  2. @broestls broestls revised this gist May 19, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions Remove_VMwareTools.ps1
    Original file line number Diff line number Diff line change
    @@ -58,6 +58,7 @@ If(Test-Path $VMware_Tools_Directory) {

    # Create a list of services to stop and remove
    $services = Get-Service -DisplayName "VMware*"
    $services += Get-Service -DisplayName "GISvc"

    # Warn the user about what is about to happen
    # Takes only y for an answer, bails otherwise.
  3. @broestls broestls revised this gist Feb 9, 2021. 1 changed file with 21 additions and 10 deletions.
    31 changes: 21 additions & 10 deletions Remove_VMwareTools.ps1
    Original file line number Diff line number Diff line change
    @@ -25,6 +25,8 @@ $reg_targets = @(
    "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\"
    )

    $VMware_Tools_Directory = "C:\Program Files\VMware"

    # Create an empty array to hold all the uninstallation targets and compose the entries into the target array
    $targets = @()

    @@ -45,21 +47,29 @@ If ([Environment]::OSVersion.Version.Major -lt 10) {
    }

    # Add the VMware, Inc regkey
    $targets += "HKLM:\SOFTWARE\VMware, Inc"
    If (Test-Path "HKLM:\SOFTWARE\VMware, Inc.") {
    $targets += "HKLM:\SOFTWARE\VMware, Inc."
    }

    # Add the VMware Tools directory
    $targets += "C:\Program Files\VMware"
    If(Test-Path $VMware_Tools_Directory) {
    $targets += $VMware_Tools_Directory
    }

    # Create a list of services to stop and remove
    $services = Get-Service -DisplayName "VMware*"

    # Warn the user about what is about to happen
    # Takes only y for an answer, bails otherwise.
    Write-Host "The following registry keys, filesystem folders, and services will be deleted:"
    $targets
    $services
    $user_confirmed = Read-Host "Continue (y/n)"
    If ($user_confirmed -eq "y") {
    If (!$targets -and !$services ) {
    Write-Host "Nothing to do!"
    }
    Else {
    $targets
    $services
    $user_confirmed = Read-Host "Continue (y/n)"
    If ($user_confirmed -eq "y") {

    # Stop all running VMware Services
    $services | Stop-Service -Confirm:$false
    @@ -70,7 +80,7 @@ If ($user_confirmed -eq "y") {
    }
    Else {
    foreach ($s in $services) {
    Write-Host "sc.exe delete $($s.Name)"
    sc.exe DELETE $($s.Name)
    }
    }

    @@ -81,7 +91,8 @@ If ($user_confirmed -eq "y") {
    }
    }
    Write-Host "Done. Reboot to complete removal."
    }
    Else {
    Write-Host "Failed to get user confirmation"
    }
    }
    Else {
    Write-Host "Failed to get user confirmation"
    }
  4. @broestls broestls revised this gist Feb 8, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Remove_VMwareTools.ps1
    Original file line number Diff line number Diff line change
    @@ -58,7 +58,7 @@ $services = Get-Service -DisplayName "VMware*"
    Write-Host "The following registry keys, filesystem folders, and services will be deleted:"
    $targets
    $services
    $user_confirmed = Read-Host "Continue (y/n): "
    $user_confirmed = Read-Host "Continue (y/n)"
    If ($user_confirmed -eq "y") {

    # Stop all running VMware Services
  5. @broestls broestls revised this gist Feb 8, 2021. 1 changed file with 26 additions and 10 deletions.
    36 changes: 26 additions & 10 deletions Remove_VMwareTools.ps1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # This script will manually rip out all VMware Tools registry entries and files for Windows 2008-2019
    # However, I only tested it on 2019
    # Tested for 2019, 2016, and probably works on 2012 R2 after the 2016 fixes.

    # This function pulls out the common ID used for most of the VMware registry entries along with the ID
    # associated with the MSI for VMware Tools.
    @@ -19,7 +19,7 @@ $vmware_tools_ids = Get-VMwareToolsInstallerID
    # Targets we can hit with the common registry ID from $vmware_tools_ids.reg_id
    $reg_targets = @(
    "Registry::HKEY_CLASSES_ROOT\Installer\Features\",
    "Registry::HKEY_CLASSES_ROOT\Installer\Features\",
    "Registry::HKEY_CLASSES_ROOT\Installer\Products\",
    "HKLM:\SOFTWARE\Classes\Installer\Features\",
    "HKLM:\SOFTWARE\Classes\Installer\Products\",
    "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\"
    @@ -28,8 +28,12 @@ $reg_targets = @(
    # Create an empty array to hold all the uninstallation targets and compose the entries into the target array
    $targets = @()

    foreach ($item in $reg_targets) {
    $targets += $item + $vmware_tools_ids.reg_id
    If ($vmware_tools_ids) {
    foreach ($item in $reg_targets) {
    $targets += $item + $vmware_tools_ids.reg_id
    }
    # Add the MSI installer ID regkey
    $targets += "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{$($vmware_tools_ids.msi_id)}"
    }

    # This is a bit of a shotgun approach, but if we are at a version less than 2016, add the Uninstaller entries we don't
    @@ -40,9 +44,6 @@ If ([Environment]::OSVersion.Version.Major -lt 10) {
    $targets += "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FE2F6A2C-196E-4210-9C04-2B1BC21F07EF}"
    }

    # Add the MSI installer ID regkey
    $targets += "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{$($vmware_tools_ids.msi_id)}"

    # Add the VMware, Inc regkey
    $targets += "HKLM:\SOFTWARE\VMware, Inc"

    @@ -59,11 +60,26 @@ $targets
    $services
    $user_confirmed = Read-Host "Continue (y/n): "
    If ($user_confirmed -eq "y") {

    # Stop all running VMware Services
    $services | Stop-Service -Confirm:$false

    # Cover for Remove-Service not existing in PowerShell versions < 6.0
    If (Get-Command Remove-Service -errorAction SilentlyContinue) {
    $services | Remove-Service -Confirm:$false
    }
    Else {
    foreach ($s in $services) {
    Write-Host "sc.exe delete $($s.Name)"
    }
    }

    # Remove all the files that are listed in $targets
    foreach ($item in $targets) {
    Remove-Item -Path $item -Recurse
    If(Test-Path $item) {
    Remove-Item -Path $item -Recurse
    }
    }
    $services | Stop-Service -Confirm:$false
    $services | Remove-Service -Confirm:$false
    Write-Host "Done. Reboot to complete removal."
    }
    Else {
  6. @broestls broestls revised this gist Feb 5, 2021. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions Remove_VMwareTools.ps1
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,8 @@ $reg_targets = @(
    "Registry::HKEY_CLASSES_ROOT\Installer\Features\",
    "Registry::HKEY_CLASSES_ROOT\Installer\Features\",
    "HKLM:\SOFTWARE\Classes\Installer\Features\",
    "HKLM:\SOFTWARE\Classes\Installer\Products\", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\"
    "HKLM:\SOFTWARE\Classes\Installer\Products\",
    "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\"
    )

    # Create an empty array to hold all the uninstallation targets and compose the entries into the target array
    @@ -63,7 +64,7 @@ If ($user_confirmed -eq "y") {
    }
    $services | Stop-Service -Confirm:$false
    $services | Remove-Service -Confirm:$false
    Write-Host "Complete. Reboot to complete removal."
    Write-Host "Done. Reboot to complete removal."
    }
    Else {
    Write-Host "Failed to get user confirmation"
  7. @broestls broestls created this gist Feb 5, 2021.
    70 changes: 70 additions & 0 deletions Remove_VMwareTools.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    # This script will manually rip out all VMware Tools registry entries and files for Windows 2008-2019
    # However, I only tested it on 2019

    # This function pulls out the common ID used for most of the VMware registry entries along with the ID
    # associated with the MSI for VMware Tools.
    function Get-VMwareToolsInstallerID {
    foreach ($item in $(Get-ChildItem Registry::HKEY_CLASSES_ROOT\Installer\Products)) {
    If ($item.GetValue('ProductName') -eq 'VMware Tools') {
    return @{
    reg_id = $item.PSChildName;
    msi_id = [Regex]::Match($item.GetValue('ProductIcon'), '(?<={)(.*?)(?=})') | Select-Object -ExpandProperty Value
    }
    }
    }
    }

    $vmware_tools_ids = Get-VMwareToolsInstallerID

    # Targets we can hit with the common registry ID from $vmware_tools_ids.reg_id
    $reg_targets = @(
    "Registry::HKEY_CLASSES_ROOT\Installer\Features\",
    "Registry::HKEY_CLASSES_ROOT\Installer\Features\",
    "HKLM:\SOFTWARE\Classes\Installer\Features\",
    "HKLM:\SOFTWARE\Classes\Installer\Products\", "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\"
    )

    # Create an empty array to hold all the uninstallation targets and compose the entries into the target array
    $targets = @()

    foreach ($item in $reg_targets) {
    $targets += $item + $vmware_tools_ids.reg_id
    }

    # This is a bit of a shotgun approach, but if we are at a version less than 2016, add the Uninstaller entries we don't
    # try to automatically determine.
    If ([Environment]::OSVersion.Version.Major -lt 10) {
    $targets += "HKCR:\CLSID\{D86ADE52-C4D9-4B98-AA0D-9B0C7F1EBBC8}"
    $targets += "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{9709436B-5A41-4946-8BE7-2AA433CAF108}"
    $targets += "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FE2F6A2C-196E-4210-9C04-2B1BC21F07EF}"
    }

    # Add the MSI installer ID regkey
    $targets += "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{$($vmware_tools_ids.msi_id)}"

    # Add the VMware, Inc regkey
    $targets += "HKLM:\SOFTWARE\VMware, Inc"

    # Add the VMware Tools directory
    $targets += "C:\Program Files\VMware"

    # Create a list of services to stop and remove
    $services = Get-Service -DisplayName "VMware*"

    # Warn the user about what is about to happen
    # Takes only y for an answer, bails otherwise.
    Write-Host "The following registry keys, filesystem folders, and services will be deleted:"
    $targets
    $services
    $user_confirmed = Read-Host "Continue (y/n): "
    If ($user_confirmed -eq "y") {
    foreach ($item in $targets) {
    Remove-Item -Path $item -Recurse
    }
    $services | Stop-Service -Confirm:$false
    $services | Remove-Service -Confirm:$false
    Write-Host "Complete. Reboot to complete removal."
    }
    Else {
    Write-Host "Failed to get user confirmation"
    }