3

我将 Bundle.wxs 中的批处理文件链接为“ExecPackage”。批处理文件需要一个参数/命令行参数。

<ExePackage Id="Test" SourceFile="D:\TestBatch.bat" Vital="yes" InstallCondition="SelectedDBSize = 24" InstallCommand=""/>

如何在“ExecPackage”中传递命令行参数/参数。可以为此使用 InstallCommand 属性吗?如果是这样,有人可以给我一个小例子来说明同样的事情吗?

4

1 回答 1

4

This is currently what I use to install SqlExpress 2008 R2 as part of my bundle:

<ExePackage Id="SqlExpress2008R2"
            Cache="no"
            Compressed="no"
            PerMachine="yes"
            Permanent="no"
            Vital="yes"
            InstallCommand="/QS /ACTION=Install /IACCEPTSQLSERVERLICENSETERMS /BROWSERSVCSTARTUPTYPE=Automatic /SQLSVCSTARTUPTYPE=Automatic /FEATURES=SQL /INSTANCENAME=[SqlInstance] /SQLSVCACCOUNT=&quot;NT AUTHORITY\Network Service&quot; /SQLSYSADMINACCOUNTS=&quot;BUILTIN\ADMINISTRATORS&quot; /AGTSVCACCOUNT=&quot;NT AUTHORITY\Network Service&quot; /SECURITYMODE=SQL /SAPWD=&quot;[SqlAdminUserPassword]&quot;"
            Name="redist\SQLEXPR_x86_ENU.exe"
            DownloadUrl="http://download.microsoft.com/download/D/1/8/D1869DEC-2638-4854-81B7-0F37455F35EA/SQLEXPR_x86_ENU.exe"
            InstallCondition="NOT SQLServer2008R2Installed AND NOT SQLServerInstalled">
    <RemotePayload ProductName="SQL Server 2008 R2 Express SP1"
                   Description="SQL Server 2008 R2 Express SP1" 
                   CertificatePublicKey="5C499B10F7EF186DC729991A262AB52066423909" 
                   CertificateThumbprint="93859EBF98AFDEB488CCFA263899640E81BC49F1" 
                   Hash="6F399D641F322A3E47E3DD605F2A2EDF21074375"  
                   Size="111274848" 
                   Version="10.50.2500.0" />
  </ExePackage>

The parts in the InstallCommand attribute surrounded with square-brackets (e.g. [SqlInstance]) are supplied by the bundle variables that can be supplied to the bundle exe on the command-line:

<Variable Name="SqlInstance"
          Value="SQLEXPRESS"
          bal:Overridable="yes" />

Note the important attribute bal:Overridable="yes" this means that it can be set via the bundles command-line, without it it will just be an internal variable (set by registry search for example).

于 2013-02-26T13:17:02.950 回答