Jump to content

Run as Admin?


Recommended Posts

Okay, so, i just recently got AutoIt the other day, and i have been playing around with it since. Now, i have a Vista computer, and whenever i want to run something as administrator, a window pops up and all that. Is there someway to write a script that can run something as Administrator, and then click accept or just completly skip the whole UAC window pop- op?

Here is what i have so far:

$answer = MsgBox(4, "Password Changer", "If you would like to change the password, click Yes.")

If $answer = 7 Then

MsgBox(0, "Password Changer", "Okay, fine, keep things the way they are.")

Exit

EndIf

Run("cmd.exe")

WinWaitActive("C:\Windows\system32\cmd.exe")

Send("net user owner *{enter}")

Sleep(500)

Send("password{enter}")

Sleep(500)

Send("password{enter}")

The only problem with this is that it is running the cmd as an ordinary user, and not as an admin. Is there a script that will allow me to run files as administrator?

Link to comment
Share on other sites

You can also change the the UAC (User Account Control) true function, by going into secpol.msc and editting the local policies - security options. I have 10 options that I can change in there, it is the closest thing your get to having Windows 7 which has 9 function in the User Control alone.

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

I don't think #RequireAdmin is what you are looking for... it will not automatically give admin rights to the script, it just checks to see if you have the required rights, and prompts you accordingly if you don't.... or at least thats how I read it (I don't have Vista)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Link to comment
Share on other sites

Oh okay. Here is what i am trying to create a script for just to see if i can do it(apparently i cannot, lol)

In vista, in order to remotely change the password using the command prompt (cmd.exe), you have to run it as administrator. in order for you to do this, you have to right click, and say "run as administrator". doing this pops up the UAC window, and i am having trouble writing a script that will work with this window. It seems almost as though this window stops all background processes. Any way to get around this?

Link to comment
Share on other sites

I don't think #RequireAdmin is what you are looking for... it will not automatically give admin rights to the script, it just checks to see if you have the required rights, and prompts you accordingly if you don't.... or at least thats how I read it (I don't have Vista)

Depending on if the user is Admin already it will say your elevated permission are granted. However if you are a standard user you will get a box saying to put in the password of admin, this is the same thing as putting the commandline username and password.

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

I don't have Vista, but would not RunAs do the trick?

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...