将登录用户加入本地管理员组!

如下脚本是将登录用户加入本地管理员组,保存为VBS脚本。作为计算机启动脚本!

strComputer = "."
Dim LocalGroup
Dim LocalComputer
Set WshNetwork = WScript.CreateObject("WScript.Network")
LocalComputer = WshNetwork.ComputerName
Set LocalGroup = GetObject("WinNT://" + LocalComputer + "/Administrators,Group")
Set objNet = CreateObject("Wscript.Network")
strDomain = objnet.UserDomain
strUser = objnet.UserName
Set objAdmins = GetObject("WinNT://" & strComputer & "/Administrators")
Set objGroup = GetObject("WinNT://" & strDomain & "/" & strUser &"")
If LocalGroup.IsMember("WinNT://" & strDomain & "/" & strUser &"") Then
WScript.Quit
Else
objAdmins.Add(objGroup.ADsPath)
End If

你可能感兴趣的:(脚本)