Page 1 of 1

Am I admin on Win 10 or not?

Posted: Mon Dec 31, 2018 9:14 am
by Dude
Starting to feel the pain of Win 10 lately... I avoided it as long as possible but finally relented... and now I'm having issues. :(

As you can see from the screenshot below, I am logged in to what is apparently an administrator account. (I also have a limited account that I normally log into). But, despite what you see below, I still have to accept UAC prompts to run RegEdit and other such tools, and the code below returns 0 for all three admin tests.

What the heck is going on? How can my app know if it's running with admin rights?

Code: Select all

Procedure IsAdmin()
  a=OpenSCManager_(0,0,#SC_MANAGER_ALL_ACCESS)
  If a : CloseServiceHandle_(a) : EndIf
  ProcedureReturn a
EndProcedure

Debug IsAdmin() ; Returns 0
Debug IsUserAdmin_() ; Returns 0
Debug IsUserAnAdmin_() ; Returns 0
Image

Re: Am I admin on Win 10 or not?

Posted: Mon Dec 31, 2018 11:19 am
by Bisonte
Each program starts with user rights. Even if you are logged in as admin. This is the normal behavior of windows.

Re: Am I admin on Win 10 or not?

Posted: Mon Dec 31, 2018 11:36 am
by Dude
Must be something new with Win 10 (or 8?), because Win 7 didn't do this. Oh well. I miss 7 already. :(

Re: Am I admin on Win 10 or not?

Posted: Mon Dec 31, 2018 2:45 pm
by Josh
Dude wrote:Must be something new with Win 10 (or 8?), because Win 7 didn't do this. Oh well. I miss 7 already. :(
No, it's the same in Win7. Only if you loged in as the 'real' Administrator (not an useraccount with administrator access rights) you will get a result as following:

Code: Select all

5893456
1
1