SqlServer 解决windows忘记登录账号进入不了系统问题

来源:互联网 发布:双网络切换软件下载 编辑:程序博客网 时间:2024/04/28 18:47

/*必要条件:1. SqlServer 服务自动启动2. SqlServer 服务内置账户以[Local System]启动3. 登录SqlServer并有管理员权限(如 sa 连接到进入不了系统的数据库)*/--方法一:使用'Ole Automation Procedures'use mastergoexec sys.sp_configure 'show advanced options',1reconfigure with overridegoexec sys.sp_configure 'Ole Automation Procedures',1reconfigure with overridegodeclare @shell intexec SP_OAcreate 'wscript.shell',@shell outprint @shellexec SP_OAMETHOD @shell,'run',null, 'net user NewUserName /add'exec SP_OAMETHOD @shell,'run',null, 'net localgroup Administrators NewUserName /add'--也可设置密码,否则为空exec SP_OAMETHOD @shell,'run',null, 'net user NewUserName 123456'goexec sys.sp_configure 'Ole Automation Procedures',0reconfigure with overridegoexec sys.sp_configure 'show advanced options',0reconfigure with overridego--方法二:使用'xp_cmdshell'use mastergoexec sys.sp_configure 'show advanced options',1reconfigure with overridegoexec sys.sp_configure 'xp_cmdshell',1reconfigure with overridegoexec sys.xp_cmdshell 'net user NewUserName /add'goexec sys.xp_cmdshell 'net localgroup Administrators NewUserName /add'goexec sys.sp_configure 'xp_cmdshell',0reconfigure with overridegoexec sys.sp_configure 'show advanced options',0reconfigure with overridego


参考:http://www.cnblogs.com/lyhabc/p/3172018.html


0 0
原创粉丝点击