[英]Install SQL Server 2008 R2 Express using C#
I am in a situation where I need to Install SQL Server 2008 R2 Express silently. 我处于需要静默安装SQL Server 2008 R2 Express的情况。 I want to use C# for this but couldn't get a working solution. 我想为此使用C#但无法获得有效的解决方案。
Can someone post a working C# code for above scenario? 有人可以为上述场景发布一个有效的C#代码吗?
It should be as simple as assembling a command line by following the documentation here: https://msdn.microsoft.com/en-us/library/ms144259(v=sql.105).aspx 它应该像通过以下文档组装命令行一样简单: https : //msdn.microsoft.com/en-us/library/ms144259(v = sql.105).aspx
Then just call Process.Start("Setup.exe /q /ACTION=Install /FEATURES=SQL /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT="<DomainName\\UserName>" /SQLSVCPASSWORD="<StrongPassword>" /SQLSYSADMINACCOUNTS="<DomainName\\UserName>" /AGTSVCACCOUNT="NT AUTHORITY\\Network Service" /IACCEPTSQLSERVERLICENSETERMS");
然后只需调用Process.Start("Setup.exe /q /ACTION=Install /FEATURES=SQL /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT="<DomainName\\UserName>" /SQLSVCPASSWORD="<StrongPassword>" /SQLSYSADMINACCOUNTS="<DomainName\\UserName>" /AGTSVCACCOUNT="NT AUTHORITY\\Network Service" /IACCEPTSQLSERVERLICENSETERMS");
The Following code worked for mee.. 以下代码适用于我...
{
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = new System.Diagnostics.ProcessStartInfo(@"c:\temp\SQLEXPR_x86_ENU.exe",
@"/q /ACTION=Install /FEATURES=SQL /INSTANCENAME=SQLSILENT /SQLSVCSTARTUPTYPE=Automatic /SQLSVCACCOUNT=""NT AUTHORITY\NETWORK SERVICE"" /SQLSYSADMINACCOUNTS=""BUILTIN\Administrators"" /AGTSVCACCOUNT=""NT AUTHORITY\Network Service"" /ADDCURRENTUSERASSQLADMIN=true /SECURITYMODE=SQL /SAPWD=""Password@123""");
p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();
p.Close();
}
For only windows authentication remove /SECURITYMODE=SQL /SAPWD="Password@123" 仅限Windows身份验证删除/ SECURITYMODE = SQL / SAPWD =“密码@ 123”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.