【问题标题】:uninstalling applications using SCCM SDK使用 SCCM SDK 卸载应用程序
【发布时间】:2016-02-09 00:02:05
【问题描述】:

我一直在尝试卸载使用 SCCM 的设备或用户上的应用程序。我已成功创建将安装应用程序的应用程序分配,但我无法将其卸载。我一直使用的代码是:

IResultObject assignment = this.manager.CreateInstance("SMS_ApplicationAssignment");
IResultObject application =
        this.manager.GetInstance("SMS_Application.CI_ID=16777339");

assignment["ApplicationName"].StringValue = application["LocalizedDisplayName"].StringValue;
assignment["AssignedCI_UniqueID"].StringValue = application["CI_UniqueID"].StringValue;
assignment["AssignedCIs"].IntegerArrayValue = new[] { application["CI_ID"].IntegerValue};
assignment["AssignmentName"].StringValue = "Deepak's deployment";
assignment["CollectionName"].StringValue = "Deepak's Collection of Devices";
assignment["DisableMomAlerts"].BooleanValue = true;
assignment["NotifyUser"].BooleanValue = false;
assignment["OfferFlags"].IntegerValue = 0;
assignment["DesiredConfigType"].IntegerValue = 1;           
assignment["OverrideServiceWindows"].BooleanValue = false;
assignment["RebootOutsideOfServiceWindows"].BooleanValue = false;
assignment["SuppressReboot"].IntegerValue = 0;
assignment["TargetCollectionID"].StringValue = "UKN0000F";
assignment["EnforcementDeadline"].DateTimeValue = DateTime.Now.AddDays(1);
assignment["StartTime"].DateTimeValue = DateTime.Now;
assignment["UseGMTTimes"].BooleanValue = false;
assignment["UserUIExperience"].BooleanValue = false;
assignment["WoLEnabled"].BooleanValue = false;
assignment["RequireApproval"].BooleanValue = true;
assignment["OfferTypeId"].IntegerValue = 2;
assignment.Put();

此代码会将应用程序设置为 SCCM 中的安装部署。如何将其作为卸载部署获取? 有一个AppAction 枚举,我怀疑它是由客户端使用的,而不是在服务器上。

typedef enum AppAction
{
    appDiscovery = 0, 
    appInstall = 1, 
    appUninstall = 2
} AppAction;

任何帮助将不胜感激!

【问题讨论】:

    标签: sccm


    【解决方案1】:

    需要更改的设置是DesiredConfigType

    对于您的代码,在 put() 之前添加以下内容:

    assignment["DesiredConfigType"].IntegerValue = 2;
    

    值 1 表示安装(必需),2 表示卸载(不允许)。

    https://msdn.microsoft.com/en-us/library/hh949014.aspx

    【讨论】:

      【解决方案2】:

      我这样做的方法是首先使用uninstall.exe 确定程序的guid,然后为我要卸载的包创建一个程序,然后调用uninstall.exe /whatever 作为命令。这适用于显示在添加/删除中的大多数应用程序,如果它没有显示在那里,那么无论如何它都必须是一个 hack(或脚本)才能卸载。我相信你失败的原因是因为如果在 sccm 中没有卸载 deployment 的命令,那么它就没有什么可运行的了。

      创建卸载程序后,您可以从代码中调用该部署,瞧。

      【讨论】:

        【解决方案3】:

        只要您尝试使用的目标程序是通过 MSI(Microsoft 安装程序)安装的,您就可以循环访问注册表以找到您的产品(注册表位置:“HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\卸载") 并查看每个 DisplayName 值。

        在我们的环境中,我使用 Powershell 完成了这项任务,并且我们设置了一个专门卸载我们所追求的程序的程序。

        希望这会有所帮助... 大发雷霆。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-08-09
          • 1970-01-01
          • 1970-01-01
          • 2017-07-10
          • 2010-09-11
          • 2021-05-06
          • 1970-01-01
          相关资源
          最近更新 更多