WMIC returns error when querying product

1

I'm trying to automate the installation of an MSI on my server, however before the installation can go ahead I need to uninstall the previous version from the server.

Searching on the internet I've found that WMIC is the tool required but there seems to be a problem with the setup of WMI on the server. Running the following command gives errors:

command prompt>wmic

then inside the tool

/trace:on

product get name

This returns a long string of successes and one failure:

FAIL: IEnumWbemClassObject->Next(WBEM_INFINITE, 1, -, -)
Line:    396 File: d:\nt\admin\wmi\wbem\tools\wmic\execengine.cpp

Node - ENTECHORELDEV
ERROR:
Code = 0x80041010
Description = The specified class is not valid.
Facility = WMI

I'm trying to run this on a standard install of Windows Server 2003 R2 with administrator privelages.

Thanks

Stu

windows
windows-server-2003
automated-install
wmi
asked on Server Fault Feb 25, 2010 by (unknown user)

2 Answers

1

There are many ways to automate (un)installation of MSIs, WMIC being one of them. Have you thought about a simpler approach, like a batch file that does:

rem Uninstall old program:
msiexec /qb /x {05EC21B8-4593-3037-A781-A6B5AFFCB19D}
rem Install new program:
msiexec /qb /i MyNewProgram.msi

(of course, replacing the GUID above with your program's GUID or Uninstall key name).

Or, you could use the Automation interface to the Windows Installer.

Or, you could use WMI via VBScript or PowerShell to accomplish the same thing as WMIC will do. But it looks like WMI might be a bit hosed.

I don't have a fix for what I'm seeing, but I do have a couple of things you can try. I recently spent a bit of time troubleshooting WMI issues, so maybe a couple of those same techniques will work here.

First, here is a VBScript that should output the same thing as product get name. Save it to a file getProductNames.vbs and execute it.

Option Explicit

Dim strComputer
Dim objWMIService, colProducts, objProduct
Dim arrstrProducts(), i

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProducts = objWMIService.ExecQuery("Select * From Win32_Product")

i = 0
For Each objProduct in colProducts
    ReDim Preserve arrStrProducts(i)
    arrStrProducts(i) = objProduct.Name
    i = i + 1
Next

WScript.Echo Join(arrStrProducts, vbNewLine)

Now, if that works, then try the same thing with wbemtest.

  1. Launch the wbemtest program.
  2. Click Connect...
  3. Change root\default to root\cimv2, then click Connect.
  4. Click Query...
  5. Enter Select * from Win32_Product, then click Apply.

This should return a list of products. If it does, then WMI is probably fine, and something is up with WMIC. If the script worked, but this did not, try the following at a Command Prompt:

regsvr32 wbemdisp.dll

then run the wbemtest query again.

If neither the script nor the wbemtest work, then probably WMI is super hosed, and you'll have to repair it.

answered on Server Fault Feb 26, 2010 by fission
0

Have you verified that the WMI Provider is enabled? It is not installed by default on some versions of Windows.

Add/Remove Programs -> Add/Remove Windows Components -> Manaagement and Monitoring Tools -> WMI Windows Installer Provider.

answered on Server Fault Apr 15, 2010 by Jeremy

User contributions licensed under CC BY-SA 3.0