Am I admin on Win 10 or not?

Windows specific forum
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Am I admin on Win 10 or not?

Post 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
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: Am I admin on Win 10 or not?

Post by Bisonte »

Each program starts with user rights. Even if you are logged in as admin. This is the normal behavior of windows.
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Am I admin on Win 10 or not?

Post by Dude »

Must be something new with Win 10 (or 8?), because Win 7 didn't do this. Oh well. I miss 7 already. :(
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Am I admin on Win 10 or not?

Post 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
sorry for my bad english
Post Reply