WiX / SetupBuilder在vbscript中获取INSTALLDIR的值

时间:2019-04-30 09:05:50

标签: gradle vbscript wix

要创建MSI,请使用Gradle插件SetupBuilder

安装后,我需要从安装目录执行二进制文件。但是我无法访问INSTALLDIR属性:

msi {
  postinst = '''
MsgBox ("INSTALLDIR: " & Session.Property("INSTALLDIR"))
'''
}

但是:

INSTALLDIR is empty

我发现SetupBuilder在.wxs文件中创建了以下自定义操作:

    <CustomAction Execute="deferred" Id="Postinst_Script0" Impersonate="no" Script="vbscript">
MsgBox ("INSTALLDIR: " &amp; Session.Property("INSTALLDIR"))
</CustomAction>

<CustomAction Id="SetPropertiesPostinst_Script0" Property="Postinst_Script0" Value="INSTALLDIR='[INSTALLDIR]';ProductCode='[ProductCode]';INSTANCE_ID='[INSTANCE_ID]'"/>

然后这样称呼他们:

<InstallExecuteSequence>
  <Custom Action="Postinst_Script0" Before="InstallFinalize">NOT Installed OR REINSTALL OR UPGRADINGPRODUCTCODE</Custom>
  <Custom Action="SetPropertiesPostinst_Script0" Before="Postinst_Script0"/>
</InstallExecuteSequence>

根据CustomAction Element上的WiX文档,PropertyValue的组合应产生Custom Action Type 51,这几乎让我迷失了方向。只是为了访问简单的属性,太多未知的东西就无法理解。

有人可以帮助我理解吗?如何访问酒店?

2 个答案:

答案 0 :(得分:1)

您的问题可能有几种答案:

  1. MSI软件包不包含user_name属性,因为它是非标准属性,应明确创建。
  2. 您正在尝试通过延迟的自定义操作来访问它。这将不起作用,因为在延迟模式下只能使用有限数量的属性。要访问任何其他属性,您应该使用<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "my_db"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, user_email, user_name, user_track FROM demo_data ORDER BY id DESC"; $option = ''; $artist = ''; $track = ''; $result = $conn->query($sql); while($row = $result->fetch_assoc()){ $option .= '<option value = "'.$row['user_email'].'">'.$row['user_email'].'</option>'; $track .= '<input type="text" name="track" required value = "'.$row['user_track'].'">'; $artist .= '<input type="text" name="artist" required value = "'.$row['user_name'].'">'; } ?> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Admin</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="main"> <h1>Accepted demo</h1> <form action="demo.php" method="post"> <select name="select"> <?php echo $option; ?> </select><br><br> <?php echo $track; ?><br><br> <?php echo $artist; ?><br><br> <input type="date" name="date" placeholder="Release Date" required> <br><br> <input style="margin-top:10px;" class="btn" type="submit" value="Send email"> </form> </body> </html> <?php $conn->close(); ?> 属性。您可以阅读有关herehere的更多信息。

答案 1 :(得分:1)

您可以尝试:

final price = 123;
final formater = NumberFormat("#,##0.000");
print(formater.format(price));

如果这项工作可以尝试:

MsgBox ("CustomActionData: " & Session.Property("CustomActionData"))