Here is what Management Studio does to change the authentication mode from mixed to Windows:
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 1;
And from Windows just before mixing:
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2; -- only difference is right here
You can invoke the same command from different sources that can connect to SQL Server, such as SQLCMD, PowerShell, VBScript, C #, etc. Or you can directly register with the server, go to this registry key and change the value manually (as suggested by @marc_s).
Note that in all cases, you must restart SQL Server for the changes to take effect. You can view the first few entries in the new reboot error log to verify that the authentication mode is correct. He will say (for mixed):
date/time Server Authentication Mode is MIXED.
Aaron bertrand
source share