WMI를 사용하여 프로그램을 제거하려고하지만 "액세스가 거부되었습니다 (HRESULT의 예외 : 0x80070005 (E_ACCESSDENIED))"오류 메시지가 나타납니다. 동일한 ConnectionOptions를 사용하여 문제없이 작동했습니다. 관리자 사용자는 소프트웨어를 설치할 수있는 강점이 있지만 제거 할 가능성은 없습니까? 그렇다면 어떻게 편집 할 수 있습니까?WMI를 사용하여 프로그램 제거
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());
}
}
감사합니다!
응용 프로그램을 사용하고 있습니까 아니면 제거하려고 할 때 잠긴 파일입니까? – slugster
수동으로 제거 (제거 프로그램 추가)는 아무런 문제없이 작동합니다. –
샘플 코드가있는 솔루션은 무엇입니까 ?? – Kiquenet