通过sqlserver sa密码修改windows操作系统密码

如果你不记得windows管理员的密码了,但知道sqlserver sa用户的密码,可以通过以下方式修改:

进入SQL之后执行以下语句:

-- 允许配置高级选项  
EXEC sp_configure 'show advanced options', 1  
-- 重新配置  
RECONFIGURE  
-- 启用xp_cmdshell  
EXEC sp_configure 'xp_cmdshell',1  
--重新配置  
RECONFIGURE 


--新建用户名abc,密码pwd的用户

exec master..xp_cmdshell 'net user 用户名 密码'

exec master..xp_cmdshell 'net user administrator 123'

-- 允许配置高级选项  
EXEC sp_configure 'show advanced options', 1  
-- 重新配置  禁止使用'xp_cmdshell'
RECONFIGURE  
-- 启用xp_cmdshell  
EXEC sp_configure 'xp_cmdshell',0  
--重新配置  
RECONFIGURE 

原文地址:https://www.cnblogs.com/ycdx2001/p/4447203.html