WMI خطأ فئة غير صالح (في محاولة لإلغاء تثبيت البرامج على الكمبيوتر عن بعد)

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

  •  11-07-2019
  •  | 
  •  

سؤال

جميع،       أحاول أن إلغاء تثبيت البرامج عن بعد، أنها تعمل بشكل جيد في آلات الاختبار، ولكن حصلت مشكلة في خوادم الإنتاج. آلات الاختبار ولقد استخدمت ويندوز إكس بي، ويندوز سيرفر 2003،

وآلة الإنتاج: ويندوز سيرفر 2003

وماذا يمكن أن يكون سبب هذا الخطأ، أي مساعدة ستكون أكثر تقدير. إذا كان لديك أي وسيلة أخرى لunistall برنامج على جهاز الكمبيوتر عن بعد، يرجى حصة.

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.ThrowWithExtendedInfo (ManagementStatus رمز الخطأ)    في System.Management.ManagementObject.Initialize (منطقية GETOBJECT)    في System.Management.ManagementObject.get_ClassPath ()    في System.Management.ManagementObject.GetMethodParameters (سلسلة METHODNAME، ManagementBaseObject وinParameters، IWbemClassObjectFreeThreaded وinParametersClass، IWbemClassObjectFreeThreaded وoutParametersClass)    في System.Management.ManagementObject.InvokeMethod (سلسلة METHODNAME، كائن [] وسائط)

هل كانت مفيدة؟

المحلول

وWIN2003 ليس لديه هذه الفئة مثبتة افتراضيا - لديك لتثبيته يدويا من القرص المنتج

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top