Page 2 of 2

Re: How to check windows administrative privilege?

Posted: Sun Jun 20, 2010 5:57 pm
by alemrantareq
All the above VBScripts will not work if you disable your LAN connection from the system tray. :o

Re: How to check windows administrative privilege?

Posted: Tue Aug 03, 2010 7:37 pm
by alemrantareq
Hey, I've found a vbscript -

Code: Select all

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
I put the above code into a vbs file & then run it; it just works very fine. But if I put it into rev custom property & try to execute, it says "execution error". I think it needs some modifications for using in rev. Someone pls, help me :)

Re: How to check windows administrative privilege?

Posted: Wed Aug 04, 2010 9:19 am
by Mark
I'm not sure that it will actually help, alemrantareq, but what happens if you delete "Set " from your script?

Best,

Mark

Re: How to check windows administrative privilege?

Posted: Wed Aug 04, 2010 3:34 pm
by alemrantareq
Same problem :(

Re: How to check windows administrative privilege?

Posted: Wed Aug 04, 2010 6:46 pm
by Mark
Hi,

I think you need to remove Wscript.Echo because this is a kind of GUI element that RunRev can't work with. Just return the variable isAdministrator in the result.

Best,

Mark

Re: How to check windows administrative privilege?

Posted: Thu Aug 05, 2010 5:18 pm
by alemrantareq
Yahooo !!! At last I've succeeded in the vbscript -

Code: Select all

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
    result = "admin"
Else
    result = "not admin"
End If
Just replaced the "Wscript.Echo" with "result =".

Now I think this one is the most accepted vbscript to check user administrative privileges both for them who have net connections or not. :D

Re: How to check windows administrative privilege?

Posted: Thu Aug 05, 2010 10:33 pm
by Mark
Cool, Alemrantareq, and thanks for posting this. This is very useful for me.

Best,

Mark