Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have to constantly switch back and forth between two installations of a web app with two different versions of an ActiveX control. Therefore I'd like to script the ability to uninstall this control. Its does not show up in Win32_Product because it was not installed via windows installer, and contrary to this answer, the Win32_ClassicCOMClass does not contain this ActiveX control.

AXHelper shows the control in HKEY_CLASSES_ROOT\CLSID. So my two questions are:

  • How do I enumerate the control with WMI
  • How do I uninstall the control with WMI
share|improve this question

You can usually find the activex ocx file in C:\windows\Downloaded Program Files.

To uninstall use cmd in powershell as cmd /c 'regsvr32 /u "C:\windows\Downloaded Program Files\youractivex.ocx"

Use $lastexitcode to verify success

Once it's uninstalled remove the ocx file from the downloaded program files folder and copy in the ocx file for the different version then install just as the uninstall command but without the /u

share|improve this answer
James, the program is not stored there, but I know where it is. I will try this later today. – Justin Dearing Jul 20 '11 at 13:05
That uninstalls the OCX, but does not remove it from the Programs and Features (Add Remove Programs on XP and previous). – Justin Dearing Jul 25 '11 at 12:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.