使用WMI卸载应用程序 [英] Using WMI to uninstall programs

查看:448
本文介绍了使用WMI卸载应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想卸载使用WMI的程序,但我得到这个错误:访问被拒绝(异常来自HRESULT:0X80070005(E_ACCESSDENIED))。安装它的工作没有任何问题,使用相同的ConnectionOptions。
是否有管理员用户 - 瑞安装软件,但不卸载任何可能性?如果是这样,我怎么可以编辑这些?

I want to uninstall a program using WMI, but I get this error : "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))". Installing it worked without any problems, using the same ConnectionOptions. Is there any possibility that the Administrator user has rigths to install software, but not to uninstall? If so, how can I edit them?

Main()
{
        ConnectionOptions oConn = new ConnectionOptions();
        oConn.Impersonation = ImpersonationLevel.Impersonate;
        oConn.EnablePrivileges = true;
        oConn.Username = "Administrator";
        oConn.Password = "password";

        System.Management.ManagementScope oMs = 
            new System.Management.ManagementScope("\\\\192.168.14.128\\root\\cimv2", oConn);

        Uninstall(oMs, "\\\\192.168.14.128\\root\\cimv2:Win32_Product.IdentifyingNumber=    \"{926C96FB-9D0A-4504-8000-C6D3A4A3118E}\",Name=\"Java DB 10.4.2.1\",Version=\"10.4.2.1\"");

}

    static void Uninstall(ManagementScope oMs, string path)
    {
        if (!oMs.IsConnected) oMs.Connect();
        ManagementObject product = new ManagementObject(path);

        if ((product != null) && (product.Path.ClassName ==
        "Win32_Product"))
        {
            object result = product.InvokeMethod("Uninstall", null); //here is where I get the error
            Console.WriteLine("The Uninstall method result is {0}",
            result.ToString());
        }
   }

感谢您!

推荐答案

您XP的机器上这样做呢?我只是谷歌-D您的错误号码,有一对夫妇链接到本: http://www.0x80070005.net/。有很多的有关问题的信息,这里是一个复制和粘贴:

Are you doing this on an XP machine? I just Google-d your error number and got a couple links to this: http://www.0x80070005.net/. There's a lot of information about the problem, and here's a copy and paste:

错误0X80070005当
A计划任务经常发生在任务计划在
视窗损坏,则需要
安装安全更新,将
收到一条错误消息。错误
消息通常显示拒绝访问。
这需要一个漏洞任务
调度,这将允许代码
执行。这些安全更新这是在早期的
公告发出
。这需要微软
知识库。所以很显然,
。这种错误是关于安全问题
和它在接入发现错误。

The error 0x80070005 often occurs when a scheduled task in Task Scheduler in Windows becomes corrupt, you need to install a security update which will receive an error message. The error message usually shows "Access denied". Here it needs a vulnerability task scheduler which will allow code execution. These are security updates which were issued in the earlier bulletin. This needs a Microsoft knowledge base. So it is clear that this error is about the security issue and it finds error in the access.

另外,我们使用维克斯了解我们的安装解决方案。不知道这是否是你的东西可以使用,但我想我会只是把它扔在那里。

Also, we're using WiX for our installer solution. Not sure if it' something you can use, but I figured I would just throw it out there.

这篇关于使用WMI卸载应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆