Using WMI to uninstall programs

I want to remove the 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 a chance that the admin user has installations for installing software, but not for uninstalling? 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()); } } 

Thanks!

0
source share
1 answer

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

Error 0x80070005 often occurs when a scheduled task in the Windows Task Scheduler becomes corrupt, you need to install a security update that will receive an error message. The error usually displays the message "Access denied." Here he needs a task vulnerability scheduler that will allow code execution. These are the security updates that were released in the previous bulletin. This requires a Microsoft knowledge base. Therefore, it is clear that this error is related to a security problem and it finds an error in access.

In addition, we use WiX for our installer solution. Not sure if this is something you can use, but I decided that I would just throw it away.

0
source

All Articles