WMI invalid class error (attempt to uninstall software on a remote PC)

That's it, I'm trying to remove the software remotely, it works fine on test machines, but I have problems with production servers. test machines I used windows xp, windows 2003 server,

production machine: Windows Server 2003.

what could be causing this error, any help would be much appreciated. If you have another way to unistall the software on a remote PC, share it.

public void Uninstallwithguid(string targetServer, string product,string guid, string version) { this.Project.Log(Level.Info, "Starting Uninstall " ); this.Project.Log(Level.Info, "targetServer :" + targetServer ); this.Project.Log(Level.Info, "product :" + product ); this.Project.Log(Level.Info, "guid :" + guid ); this.Project.Log(Level.Info, "version :" + version ); System.Management.ConnectionOptions connoptions = new System.Management.ConnectionOptions(); connoptions.Impersonation = System.Management.ImpersonationLevel.Impersonate; connoptions.Timeout = new TimeSpan(0, 0, 10); // 10 seconds System.Management.ManagementScope scope = new System.Management.ManagementScope(@"\\" + targetServer + @"\root\cimv2", connoptions); scope.Connect(); System.Management.ObjectGetOptions objoptions = new System.Management.ObjectGetOptions(); string test = @"\\" + targetServer + @"\root\cimv2"; string objPath = string.Format("Win32_Product.IdentifyingNumber='{0}',Name='{1}',Version='{2}'",guid, product, version); System.Management.ManagementPath path = new System.Management.ManagementPath(objPath); System.Management.ManagementObject moobj = new System.Management.ManagementObject(scope, path, null); UInt32 res1 = 0; try { res1 = (UInt32)moobj.InvokeMethod("Uninstall", null); } catch(Exception ex) { this.Project.Log(Level.Error, ex.ToString()); throw ex; } if (res1 != 0) { this.Project.Log(Level.Error, "Uninstall error " + res1.ToString()); throw new Exception("Uninstall error " + res1.ToString()); } } 

Error Description:

System.Management.ManagementException: invalid class in System.Management.ManagementException.ThrowWithExtendedInfo (ManagementStatus errorCode) in System.Management.ManagementObject.Initialize (Boolean getObject) in System.Management.ManagementObject.get_ClassPathMan (String methodName, ManagementBaseObject & inParameters, IWbemClassObjectFreeThreaded & inParametersClass, IWbemClassObjectFreeThreaded & outParametersClass) in System.Management.ManagementObject.InvokeMethod (String methodName, Object [] args)

0
source share
1 answer

Win2003 does not have this class installed by default - you need to install it manually from the product disk.

+2
source

All Articles