Installshield2016 condition

最近在用installshield制作安装包,在使用过程中真的是困难重重啊,写一个condition就要半天,真心觉得install shield中的condition就是一个无底洞啊,各种不明所以。

在这里做一下总结,以备日后不时之需!

在installshield中conditional的语法和我们平时编程时的操作符不太一样。下表是condition语法基本要素:

valuesymbol(符号) | literal(字面量) | integer(数值)
comparison-operator<(小于) | >(大于) | <=(小于等于) | >=(大于等于) | =(等于) | <>(不等于)
termvalue | value comparison-operator value | ( expression )|
Boolean-factorterm | NOT term
Boolean-termBoolean-factor | Boolean-factor AND term
expressionBoolean-term | Boolean-term OR expression
symbolproperty | %environment-variable | $component-action | ?component-state | &feature-action | !feature-state

上表需要特别注意一下几点: 

  • symbol的名字和值是大小写敏感的。
  • 环境便令的名字是大小写不敏感的。literal的文字必须在双引号内。(literal的值中不能含有双引号,因为没有转义字符,如果literal里面带有双引号,可以把它放在属性里。例如判断属性SERVERNAME中不包含引号("),可以将引号放在属性QUOTES中,然后condition可以写成 NOT SERVERNAME><QUOTES
  • 不存在的属性看作是空字符串。
  • 不支持浮点型数据。
  • 操作符和优先级和BASIC 和SQL一样。
  • 算数操作符不支持。
  • 圆括号可以重载操作符优先级。
  • operators是大小写不敏感的。
  • 对于字符串比较,带有“~”前缀的操作符表示忽略大小写的比较。
  • 一个整数和字符串比较,或者和不能转化成整数的属性值比较,会一直返回msiEvaluateConditionFalse,操作符<>一直返回msiEvaluateConditionTrue。

下表是逻辑操作符, 从上到下优先级从高到低。

 

Not
And两边都为true,返回true
Or只要有一方为true,返回true
Xor两边有一方为true,并且两方不同时为true时返回true。
Eqv两边一样返回true
ImpTRUE if left term is FALSE or right term is TRUE.

下表是比较操作符,以下操作符只能出现在两个值比较中。

OperatorMeaning
=TRUE if left value is equal to right value.
<>TRUE if left value is not equal to right value.
>TRUE if left value is greater than right value.
>=TRUE if left value is greater than or equal to right value.
<TRUE if left value is less than right value.
<=TRUE if left value is less than or equal to right value.

下表子字符串操作符。

OperatorMeaning
><TRUE if left string contains the right string.
<<TRUE if left string starts with the right string.
>>TRUE if left string ends with the right string.

我们有时候希望自定义的事件只有在应用卸载的时候才被执行,但是install shield中的ca如果不做特殊说明,实在安装卸载时都会被执行的,因此我们就需要为只在卸载时执行的事件加一些限制。官方文档上说有以下两种方法:

  1. If the action is sequenced after the InstallValidate action in the InstallExecuteSequence table, the package author may specify a condition of REMOVE="ALL" for the action in the Condition column. Note that the REMOVE property is not guaranteed to be set to ALL during an uninstall before the installer executes the InstallValidate action. Note that the quote marks around the value ALL are required in this case.(这里一定要记得加引号,我之前就是没有加,浪费了好多时间查找);
  2. If the action is sequenced after the CostFinalize action and any actions that could change the feature state, such as MigrateFeatureStates action, the action can be conditioned on the state of a particular feature or component. See Conditional Statement Syntax. Use this option to call an action during the removal of a particular feature or component, which may occur outside of the complete removal of the application.(部分卸载的时候可用)

注意:在升级安装的时候,老版本会被卸载,此时会执行RemoveExistingProducts action, 并会设置REMOVE为ALL, 因此要区分是升级或者卸载引起的REMOVE="ALL", 可以用UPGRADINGPRODUCTCODE属性,这个属性只有在RemoveExistingProducts 时调用。即如果想让你的CA在卸载的时候执行,在升级的时候不执行,可以设置condition为: REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE。 如果你想在升级的时候执行,可以设置condition为 UPGRADINGPRODUCTCODE

至于install中所有的属性,可以参考 Property Reference

 

转载于:https://www.cnblogs.com/my-sky/p/8558424.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值