一段可以查詢系統(tǒng)用戶名的sid的vbs代碼
代碼如下:
set path=wscript.createobject("wscript.shell")
usera=path.ExpandEnvironmentStrings("%username%")
name=inputbox("請(qǐng)輸入你要查詢的用戶名","sid查詢--by不追不悔",usera)
strComputer = "."
Set wbemServices = Getobject("winmgmts:\\" & strComputer)
Set wbemObjectSet=wbemServices.execquery("select sid from win32_userAccount where name='"&name&"'")
For Each mo In wbemObjectSet
sSID = mo.sid
Next
If(sSID = "")Then
WScript.Echo "對(duì)不起,無此用戶"
Else
WScript.Echo sSID
End If