vb 中獲取所有本地用戶清單

思路是分析net user的返回值,然後改成清單

Dim strText as String 
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("%COMSPEC% /C ""PING 127.0.0.1""")
Do While Not oExec.StdOut.AtEndOfStream
    strText = oExec.StdOut.ReadAll()
Loop
msgbox(strtext)

strText就是就是現在我的net user的返回值

下一步是解析strText

Uname = Split(strText, vbNewLine)
Uname = Split(Uname(4), Space(20))

Uname()數組就是所有的用戶名了


後續是一些擴展活動

首先,我要對所有用戶的密碼進行更改

這個最簡單 的方法是直接調cmd,使用net user命令來解決


key ="password"
For i = 1 To UBound(Uname)
    Usee = Uname(i - 1)
    If Usee <> "Guest" Then
        Str = "cmd.exe /c net user " & Usee & " " & Key
        Shell Str
    End If
Next i


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章