I would like to create an install package using WISE SCRIPT EDITOR, and I'm looking for the simplier and more reliable way to check if the current user (running this package) is really Administrator of the computer.

There is any information I can get from Registry ? environment variable ?

I can create a logic like > get the result of this command line "net localgroup Administrators" check if the current user is listed.

But I'm sure there is a better way to handle that.

Thank you.

Answer Summary:
Use Check Configuration action to check if user has NT administrator rights
0 Comments   [ - ] Hide Comments


Please log in to comment

Answer this question or Comment on this question for clarity



What do you want to happen if the user is not a local admin? Branch out the actions or have the script fail?

Answered 05/21/2012 by: pjgeutjens
Red Belt

Please log in to comment

I think you can use the "Check Configuration" action to check for System has/doesn't have NT administrator rights

Create the action and it should be clear what you need to fill out.

Answered 05/21/2012 by: pjgeutjens
Red Belt

Please log in to comment

Try this code: You'll need to add some logic to decide what to do if the user isn't an admin though.

Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
strUser = objNetwork.UserName 
isAdministrator = false 
Set objGroup = GetObject("WinNT://" & strComputer &  "/Administrators")

For Each objUser in objGroup.Members
     If objUser.Name = strUser Then        
 isAdministrator = true            
     End If

If isAdministrator Then
     Wscript.Echo strUser & " is a local administrator."
     Wscript.Echo strUser & " is not a local administrator."
End If

Answered 05/21/2012 by: olditguy
Second Degree Blue Belt

Please log in to comment