문제

We have a C# win Form app called "Installer" that silently installs various 3rd party software on client's system like IIS, SQL Server, AVG-Free; along with our own product. I need to automatically enable Named Pipes & TCP/IP protocols which also require a restart of SQL Server (SQLEXPRESS) Service using a batch file; OR C# win Form app; OR while installing SQL Server through command line by providing appropriate switches.
I have searched but this is very unique requirement.

도움이 되었습니까?

해결책

I have found a solution, tried it. The protocol info of SQL Server in registry is store here:

HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer\SuperSocketNetLib

This is for MSSQLSERVER instance, in case of different instance the registry path in bold gets replaced by name of that instance.

It needs restart of "SQLServer Service" of that instance.

다른 팁

If you want to avoid fiddling with the registry, the following should work.

From a sqlps prompt:

$smo = 'Microsoft.SqlServer.Management.Smo.'
$wmi = new-object ($smo + 'Wmi.ManagedComputer').
# Enable the TCP protocol on the default instance.
$uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Tcp']"
$Tcp = $wmi.GetSmoObject($uri)
$Tcp.IsEnabled = $true
$Tcp.Alter()
# Enable the named pipes protocol for the default instance.
$uri = "ManagedComputer[@Name='" + (get-item env:\computername).Value + "']/ServerInstance[@Name='MSSQLSERVER']/ServerProtocol[@Name='Np']"
$Np = $wmi.GetSmoObject($uri)
$Np.IsEnabled = $true
$Np.Alter()

And then restart SQL Server from good old cmd:

net stop MSSQLSERVER
net start MSSQLSERVER

Reference: https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/enable-or-disable-a-server-network-protocol?redirectedfrom=MSDN&view=sql-server-ver15

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top