1

我想在 Windows7 上使用 SqlExpress2008 Bootstrapper 进行全新安装,我不想使用默认的 SQLEXPRESS 实例。

我试图编辑位于以下位置的 package.xml 文件:C:\Program Files\Microsoft

SDKs\Windows\v7.0A\Bootstrapper\Packages\SqlExpress2008\en\package.xml

并更新了命令参数 instancename= CUSTOMINSTANCE

    <Command PackageFile="SQLEXPR32_x86_ENU.EXE"
             Arguments='/q /hideconsole /action=Install /features=SQL /instancename="CUSTOMINSTANCE" /enableranu=1 /sqlsvcaccount="NT Authority\Network Service" /AddCurrentUserAsSqlAdmin /skiprules=RebootRequiredCheck'
             EstimatedInstalledBytes="225000000"
             EstimatedInstallSeconds="420">

但不幸的是,它仍然创建默认SQLEXPRESS而不是CUSTOMINSTANCE

wix标签如下:

   <sql:SqlDatabase
              Id="SqlDatabaseCore"
              ConfirmOverwrite="yes"
              ContinueOnError="no"
              CreateOnInstall="yes"
              CreateOnReinstall="no"
              CreateOnUninstall="no"
              Database="MyDatabase"
              DropOnInstall="no"
              DropOnReinstall="no"
              DropOnUninstall="no"
              Instance="[SQLINSTANCE]"
              Server="[SQLSERVER]">
              <sql:SqlFileSpec
                Id="SqlFileSpecCore"
                Filename="[CommonAppDataFolder]MyCompany\Database\MyDatabase.mdf"
                Name="MyDatabase" />
              <sql:SqlLogFileSpec
                Id="SqlLogFileSpecCore"
                Filename="[CommonAppDataFolder]MyCompany\Database\MyDatabase.ldf"
                Name="MyDatabaseLog" />

<Property Id='SQLSERVER'>.</Property>
<Property Id='SQLINSTANCE'>CUSTOMINSTANCE</Property>

这是完成此任务的标准方法吗?

4

2 回答 2

0

我不知道标准,但我们将新的实例名称传递给命令行上的 SQLExpress 设置可执行文件。首先,将SQLEXPRADV_x86_ENU.exe文件解压到临时目录下,

string workingDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

string pathToSQLSetupTempDirectory = workingDir + Path.DirectorySeparatorChar + "sqlsetup";

if (!System.IO.Directory.Exists(pathToSQLSetupTempDirectory))
{
System.IO.Directory.CreateDirectory(pathToSQLSetupTempDirectory);
}

string path = Path.GetFullPath(workingDir + Path.DirectorySeparatorChar + "SQLEXPRADV_x86_ENU.exe");
string args = "/Q /X:" + pathToSQLSetupTempDirectory;

然后,构造命令行参数并运行提取的 setup.exe 文件。要防止安装管理工具,请将“/Features=SQL”添加到命令行参数:

 path = pathToSQLSetupTempDirectory + Path.DirectorySeparatorChar + "Setup.exe";
 args = "/QUIET /Action=Install /Features=SQL,Tools /InstanceName=" + instanceName +
    " /SECURITYMODE=SQL /TCPENABLED=1 /SAPWD=" + sqlSAPswd + " /SQLSYSADMINACCOUNTS=\"Builtin\\Administrators\" /SQLSVCACCOUNT=\"NT AUTHORITY\\NETWORK SERVICE\"";

http://msdn.microsoft.com/en-us/library/ms144259.aspx有更多关于支持的参数。

于 2010-04-08T23:03:18.613 回答
0

是的,这是正确的方法,只需确保在所有情况下都更改实例名称(x86 参数和 x64 参数)

于 2013-09-27T07:47:48.100 回答