Skip to content

Instantly share code, notes, and snippets.

@broestls
Last active July 10, 2026 16:46
Show Gist options
  • Select an option

  • Save broestls/f872872a00acee2fca02017160840624 to your computer and use it in GitHub Desktop.

Select an option

Save broestls/f872872a00acee2fca02017160840624 to your computer and use it in GitHub Desktop.
Force removal of VMware Tools, Program Files, and Windows Services
# This script will manually rip out all VMware Tools registry entries and files for Windows 2008-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.
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\Products\",
"HKLM:\SOFTWARE\Classes\Installer\Features\",
"HKLM:\SOFTWARE\Classes\Installer\Products\",
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\"
)
$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 = @()
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
# 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 VMware, Inc regkey
If (Test-Path "HKLM:\SOFTWARE\VMware, Inc.") {
$targets += "HKLM:\SOFTWARE\VMware, Inc."
}
# Add the VMware Tools directory
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"
# 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:"
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
# 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) {
sc.exe DELETE $($s.Name)
}
}
# Remove all the files that are listed in $targets
foreach ($item in $targets) {
If(Test-Path $item) {
Remove-Item -Path $item -Recurse
}
}
Write-Host "Done. Reboot to complete removal."
}
Else {
Write-Host "Failed to get user confirmation"
}
}
@luntrick

luntrick commented Jan 4, 2026

Copy link
Copy Markdown

Thanks to everyone for the iterative dialogue that made this script so successful.

@pirklb

pirklb commented Mar 13, 2026

Copy link
Copy Markdown

@Jason-Clark-FG Thank's, your script works fine (moving to HPE VME Essentials) on Windows Server 2025 (no VM* Service, no C:\ProgramData\VMware Folder, in the registry there are still some entries containing "VMware" e, g. in Classes which point to C:\Program Files\VMware\VMware Tools und C:\Program Files\Common Files\VMware - but I don't think these will cause a Problem in the future). The only VMware I find on the system partition is in C:\Windows\SoftwareDistribution\Download (which is the Cache for the Update service, so I see no problem with this)

@EPiSKiNG

Copy link
Copy Markdown

@Jason-Clark-FG THANK YOU SO MUCH! Really appreciate that script! Super helpful for my migrations!

@Jason-Clark-FG

Copy link
Copy Markdown

@Jason-Clark-FG Thank's, your script works fine (moving to HPE VME Essentials) on Windows Server 2025 (no VM* Service, no C:\ProgramData\VMware Folder, in the registry there are still some entries containing "VMware" e, g. in Classes which point to C:\Program Files\VMware\VMware Tools und C:\Program Files\Common Files\VMware - but I don't think these will cause a Problem in the future). The only VMware I find on the system partition is in C:\Windows\SoftwareDistribution\Download (which is the Cache for the Update service, so I see no problem with this)

Thanks @pirklb, so is there anything you think we should add to the script? We currently do not have an Windows Server 2025 deployed, so I cannot take a look around in one.

@Jason-Clark-FG

Copy link
Copy Markdown

@Jason-Clark-FG THANK YOU SO MUCH! Really appreciate that script! Super helpful for my migrations!

Glad to hear it @EPiSKiNG, it's been super helpful for us too. I just streamlined a few things I found in various places. Standing on the shoulders of giants as they say :-)

@pirklb

pirklb commented Apr 1, 2026

Copy link
Copy Markdown

@Jason-Clark-FG Thank's, your script works fine (moving to HPE VME Essentials) on Windows Server 2025 (no VM* Service, no C:\ProgramData\VMware Folder, in the registry there are still some entries containing "VMware" e, g. in Classes which point to C:\Program Files\VMware\VMware Tools und C:\Program Files\Common Files\VMware - but I don't think these will cause a Problem in the future). The only VMware I find on the system partition is in C:\Windows\SoftwareDistribution\Download (which is the Cache for the Update service, so I see no problem with this)

Thanks @pirklb, so is there anything you think we should add to the script? We currently do not have an Windows Server 2025 deployed, so I cannot take a look around in one.

Hello @Jason-Clark-FG - I think it is fine (we are currently in a poc to see, if we can switch from VMware to HPE VME. And for the poc it works "well". If we decide to move - and have to migrate more VMs - maybe I'll find some improvements for the script. If so, I will share it.

@Car10sH

Car10sH commented Apr 24, 2026

Copy link
Copy Markdown

I've tried making both of the modifications to the MSI suggested in the script (removed VM_LogStart and VM_CheckRequirements from CustomAction table), but the uninstallation fails (msiexec crash in Application event log). This worked on the previous version of VMware Tools we were using (12.5.2), but no longer works on a newer version (12.5.4). Is this method no longer viable? If so, happy to rely on the script you've provided, but it would be nice if the uninstall process worked as well. Any advice appreciated, thank you.

@mateuszdrab

Copy link
Copy Markdown

I've tried making both of the modifications to the MSI suggested in the script (removed VM_LogStart and VM_CheckRequirements from CustomAction table), but the uninstallation fails (msiexec crash in Application event log). This worked on the previous version of VMware Tools we were using (12.5.2), but no longer works on a newer version (12.5.4). Is this method no longer viable? If so, happy to rely on the script you've provided, but it would be nice if the uninstall process worked as well. Any advice appreciated, thank you.

I can only suggest that you post the details of the crash from the event log as well as running the uninstall through msiexec with verbose logging output to see where and why it crashes.

Without that, I won't be able to help, I haven't had VMware for a while.

@Car10sH

Car10sH commented Apr 24, 2026

Copy link
Copy Markdown

Thanks @mateuszdrab - I will do that.

@Car10sH

Car10sH commented Apr 29, 2026

Copy link
Copy Markdown

@mateuszdrab - I found the cause of the failure, it was CustomAction "VM_UninstGHIRestGuestHandle.869A7E00_8665_0000_83A8_EF0F76CF0001". I removed this via Orca (along with VM_CheckRequirements, didn't need to remove VM_LogStart however) and uninstall completed successfully. This affects version 12.5.4, internal version 12452, build 24964629, VM tested against is running in Azure native. I'm unable to confirm if the last part of the CustomAction name changes in other versions as this is the only version we are running in our VMware environment at present.

@SDC-SYSAD

Copy link
Copy Markdown

Just wanted to add, the Orca method worked perfectly for our 30ish VMs we bothered to migrate from VMWare to Hyper-V! Thanks for the tip!

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

@Car10sH and @SDC-SYSAD
Hi could do with some help, can you drop me an idiots guide on the steps you used to do the Orca method please?

The script used method DELETE FROM ... WHERE... which looks like standard SQL
Orca options seem to use a different syntax and I am guessing Drop Row = DELETE but I could be wrong.

@SDC-SYSAD

SDC-SYSAD commented May 15, 2026

Copy link
Copy Markdown

@Car10sH and @SDC-SYSAD Hi could do with some help, can you drop me an idiots guide on the steps you used to do the Orca method please?

I just did this:
-Find MSI in C:\Windows\Installer
-Open MSI with Orca
-CTRL + F to find VM_LogStart
-There were 3 entries in the MSI, find all 3
-Right click, Drop Row
-Save

EDIT - After editing the MSI I then use the standard Windows Settings > Apps > Uninstall on the VMWare Tools app.

That worked for me and I just rinsed and repeated all on my VMs.

@ItMan47

ItMan47 commented May 15, 2026 via email

Copy link
Copy Markdown

@SDC-SYSAD

Copy link
Copy Markdown

Thank you. Just edited my post to highlight the source of my confusion. I am seeing a complication in Car10sH post because I am on the affected tools version ☹ So I may drop that row also. Kind Regards, Nick Nicholas Kulkarni. MInstLM. Dip.Comp(open) IT Manager 5 Star Cases Limited From: SDC-SYSAD @.> Sent: Friday, May 15, 2026 3:28 PM To: SDC-SYSAD @.> Cc: Comment @.> Subject: Re: broestls/Remove_VMwareTools.ps1 You don't often get email from @.@.***>. Learn why this is importanthttps://aka.ms/LearnAboutSenderIdentification CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. @SDC-SYSAD commented on this gist.

________________________________ @Car10sHhttps://github.com/Car10sH and @SDC-SYSADhttps://github.com/SDC-SYSAD Hi could do with some help, can you drop me an idiots guide on the steps you used to do the Orca method please? I just did this: -Find MSI in C:\Windows\Installer -Open MSI with Orca -CTRL + F to find VM_LogStart -There were 3 entries in the MSI, find all 3 -Right click, Drop Row -Save That worked for me and I just rinsed and repeated all on my VMs. — Reply to this email directly, view it on GitHubhttps://gist.github.com/broestls/f872872a00acee2fca02017160840624#gistcomment-6151828 or unsubscribehttps://github.com/notifications/unsubscribe-auth/AXXETLHNTZ6COPSVH3JV5FT424SPBBFHORZGSZ3HMVZKMY3SMVQXIZNMON2WE2TFMN2F65DZOBS2WR3JON2EG33NNVSW45FGORXXA2LDOOIYFJDUPFYGLJDHNFZXJJLWMFWHKZNJGEYDONZXHE2TCMFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLKJSHA2DQOJQGI2DDJDOMFWWLKDBMN2G64S7NFSIFJLWMFWHKZNEORZHKZNENZQW2ZN3ORUHEZLBMRPXAYLSORUWG2LQMFXHIX3BMN2GS5TJOR4YFJLWMFWHKZNEM5UXG5FENZQW2ZNLORUHEZLBMRPXI6LQMU. You are receiving this email because you commented on the thread. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Sorry forgot to say, I didn't use any scripts to get rid of it. I just used the standard uninstall method within Windows, which only works once you've removed those 3 entries from the MSI.

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

Thanks @SDC-SYSAD , much appreciated I also dropped three lines with reference to @Car10sH post. About to try this in anger. Will let you know :)

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

@SDC-SYSAD
Screenshot 2026-05-15 154713
Still stuck with the above.
Didn't work. I am going to try without the modification suggested by @Car10sH and see what happens

@SDC-SYSAD

Copy link
Copy Markdown

:( That's frustrating! I wish you luck! :-)

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

@SDC-SYSAD no luck, crashes out just as @Car10sH says. It seems to be a problem with that particular version. 12.5.4.249629. I am going to have to try the script.

@Car10sH

Car10sH commented May 15, 2026

Copy link
Copy Markdown

@ItMan47 - As suggested by mateuszdrab, it is worth you running the msiexec uninstall process with verbose logging enabled, as this will help you to identify what is causing the uninstall process to fail.

  • From elevated Command Prompt, navigate to C:\Windows\Installer
  • Locate the VMware Tools MSI (usually has a hexadecimal value for a filename)
  • Run: msiexec /x <msifilename.msi> or {product_code} /L*v C:\Temp<logname.log>
  • Once the installer fails, open the log file and search for "1603" - this should give you a pointer towards the problem (that's how I found the reference to the CustomAction: VM_UninstGHIRestGuestHandle.869A7E00_8665_0000_83A8_EF0F76CF0001)

You can then remove references to whichever CustomAction it shows from the MSI via Orca.

Hope this helps!

@ItMan47

ItMan47 commented May 15, 2026 via email

Copy link
Copy Markdown

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

@Car10sH Interesting, I thought I had removed all instances of VM_CheckRequirements with Orca but I am seeing this
MSI (s) (B4:C4) [16:54:03:068]: Doing action: VM_CheckRequirements
Action ended 16:54:03: LaunchConditions. Return value 1.
MSI (s) (B4:B0) [16:54:03:083]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIAF20.tmp, Entrypoint: VMCheckRequirements
Action start 16:54:03: VM_CheckRequirements.
CustomAction VM_CheckRequirements returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
MSI (s) (B4:C4) [16:54:03:630]: Doing action: VM_SendMsiLogToHostOnError
Action ended 16:54:03: VM_CheckRequirements. Return value 3.

Double checking the MSI now.

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

CTRL+F VM_CheckRequirements returns nothing found. I am stumped.
did find this also just after that 1603

MSI (s) (B4:98) [16:54:03:646]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIB154.tmp, Entrypoint: VMSendMsiLogToHost
Action start 16:54:03: VM_SendMsiLogToHostOnError.
Action ended 16:54:03: VM_SendMsiLogToHostOnError. Return value 1.
Action ended 16:54:03: INSTALL. Return value 3.

Clearly that isn't going to work either.

@Car10sH

Car10sH commented May 15, 2026

Copy link
Copy Markdown

@ItMan47 Are you modifying the relevant MSI held in C:\Windows\Installer via Orca? I found it only works if you update that one (make a copy first just in case, give it a .bak extension or something), as that is what the uninstall process calls.

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

@Car10sH kind of, I copied this out of the folder on to another machine, edited it with orca and saved it, then copied the edited file I saved back over to the original folder.

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

@Car10sH that path you gave me C:\Windows\Installer is that correct? The VM is running a Server OS not a desktop OS. I am finding the file is in C:\Program Files\Common Files\VMware\InstallerCache. Just running a search for the Product Code to see if it is anywhere else on the machine. I found a folder with the product code in the location you gave but it only has the Icon file in it. I am going to copy the modified msi in there and see if it will execute.

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

No joy, calling it a night, hit this again on Monday, thanks to @Car10sH and @SDC-SYSAD

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

https://help.zerto.com/bundle/z-kb-articles-zertokbs/page/4336.html
_When you try to install VMware tools on a VM that's running on Hyper-V hypervisor, the installation fails.
The reason is that the VMware Tools installer checks for an underlying VMware product hosting the VM. If it isn't found, the installer won't continue. VMware tools can't be installed on a VM that's running on Hyper-V hypervisor.
The correct procedure to install the VMware tools on a VM that's running on Hyper-V is to failover the VM to the VMware environment, install the VMware tools, and then failback.

Workaround
If you want to work around the correct procedure, you can download a VMware Tools MSI and remove the table row that runs this check. If you currently have an MSI for VMware Tools, open it for editing (ORCA is a commonly used tool for this - ORCA.EXE), and remove the row “VM_CheckRequirements” from the sequence table “InstallUISequence.”_

Having removed every instance I could find with Orca I suspect the VMCheckRequirements has been hard coded into the version I have at low level. It was one of the latest released by VMWare (its a patch for a CVE) and this is long after Broadcom's takeover. That would explain the log file still calling VMCheckRequirements even after applying the workaround. This would be designed to defeat the workaround and may have broken the uninstall too.

@Car10sH

Car10sH commented May 15, 2026

Copy link
Copy Markdown

@ItMan47 Yes, C:\Windows\Installer is a common path used by both server and desktop, it is not unique to desktop. The folder will likely be hidden if you are trying to view it through Windows Explorer. This folder will hold the MSI that is called when running uninstall from GUI. The MSI in the folder will be named with a random hexadecimal string. This used to be named the same across all servers, but I have found with this version it is randomly named - in my case it is was 5554.msi, but was called 5EF6A4.msi on another server. The easiest way to identify the right MSI is to check the file size - for this specific version (for me at least), the file was 71,086,080 bytes in length. Once you've copied the modified MSI to this location with the same name, I would suggest running the uninstall process directly from an elevated command prompt from this location, much like you did when generating the verbose log file, so msiexec /x <filename.msi>. That has worked for me every single time, across multiple servers.

@ItMan47

ItMan47 commented May 15, 2026

Copy link
Copy Markdown

Hi @Car10sH thanks for the detailed update, you are correct in server 2022 that path is superhidden, only way I found to access it is to create a short cut to the folder or to type it in by hand. I will give this a go on Monday. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment