柚子Nan--回归原点

Everything can be as easy as you like or as complex as you need.
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

判断当前用户是否管理员

Posted on 2005-11-06 22:32  柚子Nan  阅读(146)  评论(0)    收藏  举报

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Wscript.echo "Computer Name: " & strComputer
strUser= objNetwork.UserName

Wscript.echo "The current User is " & strUser

Set objGroup = GetObject("WinNT://" & strComputer & "/administrators")
For Each objUser in objGroup.Members
 If objUser.Name = strUser Then
  Wscript.Echo strUser & " is a local administrator."
 End If
Next