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.
Answers (3)
Use Check Configuration action to check if user has NT administrator rights
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