Windows_exporter: Uninstall via command line not working

Created on 19 Jun 2019  路  6Comments  路  Source: prometheus-community/windows_exporter

How do you uninstall the product with the command line?

I tried msiexec.exe /i{1F2534DC-9E6D-4E81-A97E-DEEABFC23FA4} because it is listed as beeing the UninstallString.

I also tried msiexec.exe /x{1F2534DC-9E6D-4E81-A97E-DEEABFC23FA4} because according to the documentation it should be X instead of I.

But both methods just opens a msiexec help window.

Most helpful comment

Could this be documented in the README?

All 6 comments

msiexec.exe /x {your-product-code-guid}

Check your command line syntax.

Are you talking about the space?
I tried both with and without a space between the X and the opening brace but the result is the same.

Hi @fullenw1,
Just to make sure I understand you right, you got UninstallString from HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall, right?
I notice that I also get /I rather than /x, there, which is odd...
However, if I change to /x, it works. How are you running this, from a script or directly in cmd.exe? Or Powershell?

Hi @carlpett

You led me to the solution :-)
By asking "with cmd or PowerShell" I remembered that expressions between braces must be quoted in PowerShell. I had a similar issue with BCDEdit a few years ago.

This works fine:
MsiExec.exe /X"{1F2534DC-9E6D-4E81-A97E-DEEABFC23FA4}"

And this works even better because there is no interactive window:
MsiExec.exe /X"{1F2534DC-9E6D-4E81-A97E-DEEABFC23FA4}" /qn

I also tested with /I and ... it works (no error message) ... but it does nothing :-)
So the only thing you may improve is the uninstall string with X instead of I.

Now I can deploy it with peace of mind because I know how to deploy and remove it on multiple servers with the command line.

By the way, the command line you provide for the installation works fine within a RDP session.
However, it doesn't work in remote PSSessions.
This worked for me:
Invoke-Command -ComputerName MyComputer -ScriptBlock {Start-Process -FilePath C:\windows\system32\msiexec.exe -ArgumentList "/i c:\temp\wmi_exporter-0.7.0-amd64.msi /qn ENABLED_COLLECTORS=os,ad LISTEN_PORT=5000" -Wait}

Thanks for your help!
Have a nice day!

Glad it works!
Powershell parsing being different from cmd is a somewhat common issue we see :) However, when I tested it I got a PS error rather than msiexec throwing up the help window, but perhaps the logic is a bit different between versions (I tested on an insider build).
Thanks for the PSSession example!

Could this be documented in the README?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fischerman picture fischerman  路  4Comments

carlpett picture carlpett  路  7Comments

Psk8140 picture Psk8140  路  3Comments

finkr picture finkr  路  3Comments

Gerthum picture Gerthum  路  9Comments