标题: VBS生成随机帐户 [打印本页]
作者: zinet 时间: 2008-10-18 23:36 标题: VBS生成随机帐户
请问vbs命令能或自动生成6---8位随机的英文+数字帐户 。。。。。 如果能的话代码我该如何写,请高人指点,谢谢
───────────────── 版务记录 ─────────────────
执行:Batcher
操作:[2008-10-19]从"代码咨询&讨论"转移帖子到"vbs问答"
说明:发错板块
处罚:扣除10点积分
提示:建议阅读论坛发帖规则
───────────────── 版务记录 ─────────────────
[ 本帖最后由 Batcher 于 2008-10-19 11:41 编辑 ]
作者: zqz0012005 时间: 2008-10-19 08:23
用bat不行吗?- @echo off & setlocal EnableDelayedExpansion
- set str=abcdefghijklmnopqrstuvwxyz0123456789
- for /l %%a in (0 1 5) do (
- set /a n=%ramdom% %% 36
- call set strName=!strName!%%str:~!n!%%
- )
- net user %strName% /add
复制代码
作者: zqz0012005 时间: 2008-10-19 08:24 标题: vbs
- str = "abcdefghijklmnopqrstuvwxyz0123456789"
- for i=0 to 5
- Randomize
- strName = strName & mid(str,Int(36*Rnd)+1,1)
- next
- CreateObject("WScript.Shell").Run "net user " & strName & "/add" ,0
复制代码
作者: everest79 时间: 2008-10-19 08:56
建立本地账户还是使用cmd吧,用脚本很麻烦
作者: jsj30651 时间: 2008-10-19 10:38 标题: 回复 2楼 的帖子
代码拼写错了吧?复制代码
应该是复制代码
作者: rat 时间: 2008-10-20 16:33
- Option Explicit
-
- CreateUser GetRandomStr(), "", False
-
-
-
- Function GetRandomStr()
- Dim sList, iHigh, i, sResult
- sList = "0123456789abcdefghijklmnopqrstuvwxyz"
- Randomize
- iHigh = Int(3 * Rnd()) + 6
- For i = 1 To iHigh
- sResult = sResult & Mid(sList, Int(36 * Rnd() + 1), 1)
- Next
- GetRandomStr = sResult
- End Function
-
- Sub CreateUser(sName, sPass, bAdmin) '用户名、密码、是否加入管理员组
- Dim oWsh, sPC, oPC, oGroup, oUser, sResult
- Set oWsh = CreateObject("WScript.Shell")
- sPC = "WinNT://" & oWsh.ExpandEnvironmentStrings("%COMPUTERNAME%")
- Set oPC = GetObject(sPC)
- Set oGroup = GetObject(sPC & "/Administrators,Group")
- Set oUser = oPC.Create("User", sName)
-
- If sPass <> "" Then oUser.SetPassword sPass
- oUser.SetInfo
- If bAdmin Then oGroup.Add sPC & "/" & sName
-
- Set oUser = Nothing
- Set oGroup = Nothing
- Set oPC = Nothing
- Set oWsh = Nothing
- End Sub
复制代码
[ 本帖最后由 rat 于 2008-10-20 16:51 编辑 ]
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |