/build/static/layout/Breadcrumb_cap_w.png

Wise Script command to get info "Is the Current User local Admin?

Hello,

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.


0 Comments   [ + ] Show comments

Answers (3)

Answer Summary:
Use Check Configuration action to check if user has NT administrator rights
Posted by: pjgeutjens 12 years ago
Red Belt
0

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

Posted by: pjgeutjens 12 years ago
Red Belt
0

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.

Posted by: olditguy 12 years ago
Second Degree Blue Belt
0

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
Next 

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

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ