這就是我,希望它有助於:
<?define ServerInstall="SomeCondition" ?>
<?define InstanceName = "YOUR_INSTANCE" ?>
<?define SqlWebLink = http://download.microsoft.com/download/5/2/9/529FEF7B-2EFB-439E-A2D1-A1533227CD69/SQLEXPR_x86_ENU.exe ?>
<Variable Name="SqlVariable" Type="string" Value="/SAPWD=some_password" Hidden="yes" />
<!-- Read SQL Server keys to find current instance and version -->
<util:RegistrySearch
Id="SqlInstanceKeyFound"
Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" Value="$(var.InstanceName)"
Result="exists" Variable="SqlInstanceKeyFound" />
<util:RegistrySearch
Id="SqlInstanceKey"
Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" Value="$(var.InstanceName)"
Variable="SqlInstanceKey" After="SqlInstanceKeyFound" Condition="SqlInstanceKeyFound" />
<util:RegistrySearch
Id="SqlInstanceFound"
Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft SQL Server\[SqlInstanceKey]"
Result="exists" Variable="SqlInstanceFound" After="SqlInstanceKey" Condition="SqlInstanceKeyFound" />
<util:RegistrySearch
Id="SqlVersion"
Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft SQL Server\[SqlInstanceKey]\Setup" Value="Version"
Variable="SqlVersion" After="SqlInstanceKey" Condition="SqlInstanceFound" />
<PackageGroup Id="Sql2012Express">
<!--
SQL Server 2012 Express - Install new instance
http://msdn.microsoft.com/en-us/library/ms144259.aspx
SQL Server Express requires WIndows Installer 4.5
RepairCommand="/ACTION=Repair /INSTANCENAME=$(var.InstanceName) /Q /HIDECONSOLE"
-->
<ExePackage Id="Sql2012Express"
DisplayName="SQL Server 2012 Express"
Cache="yes"
Compressed="no"
PerMachine="yes"
Permanent="no"
Vital="yes"
Name="Redist\SQLEXPR_x86_ENU.exe"
SourceFile="..\Packages\SQLEXPR_x86_ENU.exe"
DownloadUrl="$(var.SqlWebLink)"
InstallCommand="/ACTION=Install /INSTANCENAME=$(var.InstanceName) /FEATURES=SQL /SECURITYMODE=SQL [SqlVariable] /TCPENABLED=1 /SQLSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /SQLSVCSTARTUPTYPE=Manual /SQLSYSADMINACCOUNTS=BUILTIN\Administrators /ADDCURRENTUSERASSQLADMIN=FALSE /Q /HIDECONSOLE /SkipRules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
UninstallCommand="/Action=Uninstall /INSTANCENAME=$(var.InstanceName) /FEATURES=SQL /Q /HIDECONSOLE"
DetectCondition="SqlInstanceFound"
InstallCondition="$(var.ServerInstall)">
<ExitCode Value ="3010" Behavior="forceReboot" />
<dep:Provides DisplayName="Net2 SQL Server 2012 Express" Key="SQLServer2012Express,$(var.InstanceName)" Version="11.0.3000.0" />
</ExePackage>
<!--
SQL Server 2012 Express - Upgrade existing pre-SQL 2012 instance
-->
<ExePackage Id="Sql2012ExpressUpgrade"
DisplayName="SQL Server 2012 Express Upgrade"
Cache="no"
Compressed="no"
PerMachine="yes"
Permanent="yes"
Vital="yes"
Name="Redist\SQLEXPR_x86_ENU.exe"
SourceFile="..\Packages\SQLEXPR_x86_ENU.exe"
DownloadUrl="$(var.SqlWebLink)"
InstallCommand="/ACTION=Upgrade /INSTANCENAME=$(var.InstanceName) /Q /HIDECONSOLE /SkipRules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
DetectCondition="NOT (SqlInstanceFound AND (SqlVersion < v11.0.0.0))"
InstallCondition="$(var.ServerInstall)">
<ExitCode Value ="3010" Behavior="forceReboot" />
</ExePackage>
<!--
SQL Server 2012 SP1 Express - Upgrade existing SQL 2012 instance to SP1
-->
<ExePackage Id="Sql2012ExpressEditionUpgrade"
DisplayName="SQL Server 2012 SP1 Express Patch"
Cache="no"
Compressed="no"
PerMachine="yes"
Permanent="yes"
Vital="yes"
Name="Redist\SQLEXPR_x86_ENU.exe"
SourceFile="..\Packages\SQLEXPR_x86_ENU.exe"
DownloadUrl="$(var.SqlWebLink)"
InstallCommand="/ACTION=Patch /INSTANCENAME=$(var.InstanceName) /Q /HIDECONSOLE /SkipRules=RebootRequiredCheck /IAcceptSQLServerLicenseTerms"
DetectCondition="NOT (SqlInstanceFound AND (SqlVersion > v11.0.0.0) AND (SqlVersion < v11.0.3000.0))"
InstallCondition="$(var.ServerInstall)">
<ExitCode Value ="3010" Behavior="forceReboot" />
</ExePackage>
您需要更改安裝命令,以符合您的要求。
我已經這樣做了使用註冊表項我不知道的WMI的建議,你可以直接我的信息?如果你喜歡,我可以分享我的註冊表鍵版本。 – Neil
請參閱http://blogs.msdn.com/b/sqlexpress/archive/2006/07/29/faq-detecting-sql-server-2005-using-wmi.aspx – RickNZ
這是指SQL 2005我想同樣可以適用於2012年,但我已經安裝了所有版本的SQL Express自MSDE以來,通過註冊表鍵檢測它 - 毫無疑問,MS更改密鑰,但主要版本之間,我從來沒有看到他們的變化。使用BA函數可以在Extended BA(http://wixextba.codeplex.com/)中實現該代碼,也可以在3.8中執行相同的代碼。 – Neil