Jump to content

How to knowl if a script was run as administrator


Darien
 Share

Recommended Posts

  • Developers
13 minutes ago, Darien said:

The "Isadmin" command only shows whether the logged account has administrator rights.

Are you sure? Strait from the helpfile:

Quote

Remarks

It returns 1 under Windows Vista only if running with a full administrator token (i.e. #RequireAdmin has been used, or has already been elevated by UAC).

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 weeks later...

Hi, 
I'm Windows10 user. Sorry if this is an out of topic question, but what should I do with my user account to get administrative rights? 
My User Account Control is set to 'Never Notify' level, and current user is a member of 'Administrators' group.

But when I use IsAdmin ()  script from example, it shows that I'm not an Admin: 

If IsAdmin() Then
    MsgBox($MB_SYSTEMMODAL, "", "IsAdmin" & @CRLF & "Admin rights are detected.")
 Else
    MsgBox($MB_SYSTEMMODAL, "", "IsAdmin" & @CRLF & "Admin rights are NOT detected.")
 EndIf

As it returns 'No Admin' rights, I should use #RequireAdmin to correctly script running. ConsoleWrite() doesn't work in that case, it's not convenient. Can I redirect Console notes to a file?

User settings.png

Link to comment
Share on other sites

  • Moderators
7 minutes ago, Elena said:

ConsoleWrite() doesn't work in that case, it's not convenient.

As the help file states, you're opening a new process which is why ConsoleWrite does not work. If you want these functions, you will need to launch SciTE as an administrator as well.

9 minutes ago, Elena said:

Can I redirect Console notes to a file?

A quick search of the forum will show you a multitude of ways to log your script's activities, from log files to the Windows Event Viewer. Choose the one that best suits your needs.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 1 month later...

I have the opposite problem... the script is elevated, I used #requireadmin and so, if I understand correctly I've started a new process as user Admin. Is there any way to know whether the user that started the script, before it was elevated (or closed and run as administrator) had admin rights. I suppose another way of looking at this is, is there a way of know whether it was elevated or if it ran as normal because the user who started it already had admin rights?

Clear as mud?

Link to comment
Share on other sites

  • Developers
49 minutes ago, Graeme said:

I used #requireadmin and so

This will only prompt to elevate when it isn't running yet with Admin rights, so there is your answer. ;)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Sounds good....

However the program is testing all kinds of things in a computer to make sure it's ready for company business. So I put all the results from the tests in a splash text... I want to say, Yes or No that the account that started the script has admin rights... can the script tell if the UAC was invoked??? The user can tell and in a way I'm happy with that but it would be nice if the script could as well..

Link to comment
Share on other sites

  • Developers

What exactly do you want to test? DO you want to know whether the user has Administrator right (is part of the Local Administrators group)  as that is a different question from whether the UAC is  enabled?

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

What I actually want to test is whether the user has admin rights... From what I've seen before, as soon as I run a script with #requireadmin, the user for that instance is admin and so has admin rights.. What I want to know is whether the user who started the script had admin rights...

Link to comment
Share on other sites

Thanks Earthshine but the problem is that there are two users. When you call #requireadmin the system closes the process and opens a new one in the user admin which has admin rights... I want to know about the first user, not the second..:(

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...