WMI无效类的错误(试图卸载远程PC软件)错误、软件、WMI、PC

2023-09-04 06:51:48 作者:男人調情是天性

所有,       我尝试远程卸载软件,它工作正常,在试验机,但我得到了在生产服务器上的问题。 试验机我已经使用的Windows XP,Windows 2003 Server的,

All, I am trying to uninstall a software remotely, it is working fine in the test machines, but i got problem in production servers. test machines i have used windows xp, windows 2003 server,

生产设备:Windows Server 2003的

production machine : windows server 2003.

这可能是此错误的原因,任何帮助会比较AP preciated。 如果你要在远程PC上反安装软件的任何其他方式,请分享。

what could be the cause of this error, any help would be more appreciated. if you have any other way to unistall a software on the remote PC, please share.

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());
		}
}

错误描述:

System.Management.ManagementException:无效的类别    在System.Management.ManagementException.ThrowWithExtendedInfo(ManagementStatus错误code)    在System.Management.ManagementObject.Initialize(布尔的getObject)    在System.Management.ManagementObject.get_ClassPath()    在System.Management.ManagementObject.GetMethodParameters(字符串方法名,ManagementBaseObject和放大器; inParameters,IWbemClassObjectFreeThreaded和放大器; inParametersClass,IWbemClassObjectFreeThreaded和放大器; outParametersClass)    在System.Management.ManagementObject.InvokeMethod(字符串方法名,对象[]参数)

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

推荐答案

Win2003的不具有此类默认安装的 - 你必须从产品光盘手动安装

Win2003 doesn't have this class installed by default - you have to install it manually from the product disc.