How to check windows administrative privilege?

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: How to check windows administrative privilege?

Post by alemrantareq » Sun Jun 20, 2010 5:57 pm

All the above VBScripts will not work if you disable your LAN connection from the system tray. :o

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: How to check windows administrative privilege?

Post by alemrantareq » Tue Aug 03, 2010 7:37 pm

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 :)

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to check windows administrative privilege?

Post by Mark » Wed Aug 04, 2010 9:19 am

I'm not sure that it will actually help, alemrantareq, but what happens if you delete "Set " from your script?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: How to check windows administrative privilege?

Post by alemrantareq » Wed Aug 04, 2010 3:34 pm

Same problem :(

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to check windows administrative privilege?

Post by Mark » Wed Aug 04, 2010 6:46 pm

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: How to check windows administrative privilege?

Post by alemrantareq » Thu Aug 05, 2010 5:18 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to check windows administrative privilege?

Post by Mark » Thu Aug 05, 2010 10:33 pm

Cool, Alemrantareq, and thanks for posting this. This is very useful for me.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply