close

SSMS中利用XP_CMDSHELL來執行net use指令建立一個網路磁碟機

XP_CMDSHELL預設是被關閉不能使用,因此先用sp_configure 來開啟XP_CMDSHELL

 1.在server按右鍵選擇Facet  將XPCmdShellEnable 設為True

2.指令開啟

 EXEC sp_configure "show advanced options", 1; 
 RECONFIGURE; 
 EXEC sp_configure "xp_cmdshell", 1; 
 RECONFIGURE; 

利用XP_CMDSHELL建立網路磁碟

  exec xp_cmdshell 'net use Y: \\網路磁碟位置 /user:帳號 密碼'

在備份時就可以選到該網路磁碟

 

-- 刪除

 exec XP_CMDSHELL 'net use Y: /delete'
-- 關閉 xp_cmdshell 
 EXEC sp_configure "show advanced options", 1; 
 RECONFIGURE; 
 EXEC sp_configure "xp_cmdshell", 0; 
 RECONFIGURE;

arrow
arrow
    文章標籤
    SQLSERVER
    全站熱搜

    JosephChou 發表在 痞客邦 留言(0) 人氣()