Archive: How to detect if user is Administrator?


How to detect if user is Administrator?
Is it possible to detect if the User running the installer/uninstaller is a administrator user? I need a way which can detect if the user has administrator rights. Now my code reads the user name from enviroment variable and checks for "Administrator" but that does not work in non-english locales and if the user has the rights but is not named as "Administrator".


Again, This was asked before. Please search the forums for this answer, and if it doesn't provide and answer, then you may post an question.

-Duane


I did look for answer but it didn't answer my question completely. I might have missed the right thread but those which I read didn't completely answer the question .. but I think I need to use external app then? .. well, maybe I just make another search on this forum..


Solution
I had the same problem! I had to be able to know if
the user had administrative privileges so that I could
install an NT service.

The only way that I could find to do it was to create a
small application myself to do the job. I have attached
it for you to use as you wish along with a sample nsi file
and the source code for the App.

It works fine under NT and 2000 but in 98/ME it just
reports that the users are not administrators - which
is fine as you can't install a service on 98/ME anyway!

Hope this helps.

Matt


I have not tested this, but you should be able to attempt to write a registry key to place that the administrator can only write to, and if it writes successfully, you are administrator.

-Justin