WMI 유효하지 않은 클래스 오류 (원격 PC에서 소프트웨어를 제거하려고)

StackOverflow https://stackoverflow.com/questions/327650

  •  11-07-2019
  •  | 
  •  

문제

모두 원격으로 소프트웨어를 제거하려고 노력하고 있으며 테스트 머신에서 잘 작동하지만 프로덕션 서버에서 문제가 발생했습니다. Test Machines Windows XP, Windows 2003 서버를 사용했습니다.

생산 기계 : Windows Server 2003.

이 오류의 원인이 될 수있는 것은 무엇이든 도움이 더 감사 할 것입니다. 원격 PC에서 소프트웨어를 방해 할 수있는 다른 방법이 있으면 공유하십시오.

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 : System.Management.ManagementException.Management.Management.Management.Management.Management.Management.Management.Management.Management.Management.Management.get_ClassPath ()의 System.Get_ClassPath ()에서 system.management.get_classpath ()에서 system.management.managementobject (boolean getObject)의 유효하지 않은 클래스. (String MethodName, ManagementBaseObject & inparameters, IWBEMCLASSOBJECTFREETHREADED & inPARAMETERSCLASS, IWBEMCLASSOBJECTFREETHREADED 및 OUTPARAMETERSCLASS) System.Management.managementObject.invokemethod (String MethodName, Object [] argss)

도움이 되었습니까?

해결책

Win2003에는 기본적 으로이 클래스가 설치되어 있지 않습니다. 제품 디스크에서 수동으로 설치해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top