首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WMI无效类错误(尝试卸载远程pc上的软件)

WMI无效类错误(尝试卸载远程pc上的软件)
EN

Stack Overflow用户
提问于 2008-11-29 16:05:08
回答 1查看 4K关注 0票数 0

总之,我正在尝试远程卸载一个软件,它在测试机器上运行良好,但我在生产服务器上遇到了问题。测试机器我使用过windows xp,windows 2003 server,

生产机器: windows server 2003。

什么可能是这个错误的原因,任何帮助都将不胜感激。如果您有任何其他方法可以卸载远程PC上的软件,请共享。

代码语言:javascript
复制
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.ThrowWithExtendedInfo(ManagementStatus上无效的类)在System.Management.ManagementObject.Initialize(Boolean上)在System.Management.ManagementObject.get_ClassPath()上) System.Management.ManagementObject.GetMethodParameters(String methodName,ManagementBaseObject& inParameters,IWbemClassObjectFreeThreaded& inParametersClass,IWbemClassObjectFreeThreaded& outParametersClass)在System.Management.ManagementObject.InvokeMethod(String methodName上,Object[]参数)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2008-11-30 15:59:00

默认情况下,Win2003不会安装此类别-您必须从产品光盘手动安装。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/327650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档