使用WMI卸载程序

我想使用WMI卸载程序,但是我收到此错误:“访问被拒绝。(HRESULTexception:0x80070005(E_ACCESSDENIED))”。 使用相同的ConnectionOptions安装它没有任何问题。 管理员用户是否有可能安装软件但不能卸载? 如果是这样,我该如何编辑它们?

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机上做这个吗? 我只是谷歌你的错误号码,并得到一些链接: http : //www.0x80070005.net/ 。 有很多关于这个问题的信息,这里有一个复制和粘贴:

当Windows中的任务计划程序中的计划任务损坏时,通常会发生错误0x80070005,您需要安装将收到错误消息的安全更新。 错误消息通常显示“拒绝访问”。 这需要一个允许代码执行的漏洞任务调度程序。 这些是在早期公告中发布的安全更新。 这需要Microsoft知识库。 所以很明显,这个错误是关于安全问题的,它在访问中发现错误。

此外,我们正在使用WiX作为我们的安装程序解决方案。 不确定它是否可以使用,但我想我会把它扔出去。