2011-08-15 75 views

回答

1

的別名存儲在註冊表中,這樣一個註冊表文件會做的伎倆。有些選項

  • 部署,爲用戶.reg文件雙擊
  • 使用遠程註冊表中創建您的設置實用程序中的條目
  • ,包括寄存器條目
0

下面是我用作起點的基本BAT腳本:

set DBSERVERALIAS=AliasName 
set DBSERVER=RealServerName 
rem %windir%\system32\cliconfg.exe 
reg add HKLM\Software\Microsoft\MSSQLServer\Client\ConnectTo /v %DBSERVERALIAS% /t REG_SZ /d "DBMSSOCN,%DBSERVER%" /f 
reg query HKLM\Software\Microsoft\MSSQLServer\Client\ConnectTo 
rem 64-bit support for database alias 
rem %windir%\SysWOW64\cliconfig.exe 
if /i NOT "%PROCESSOR_ARCHITECTURE%" == "X86" (
    reg add HKLM\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo /v %DBSERVERALIAS% /t REG_SZ /d "DBMSSOCN,%DBSERVER%" /f 
    reg query HKLM\Software\Wow6432Node\Microsoft\MSSQLServer\Client\ConnectTo