Sign in to follow this  
Followers 0
Hacker4All

Run as Admin?

16 posts in this topic

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?

Share this post


Link to post
Share on other sites



#RequireAdmin allows you to run as admin


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites

#RequireAdmin allows you to run as admin

So, if i wanted to run cmd as admin, i would write in the script: #requireAdmin("cmd.exe") right?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

No you put

#RequireAdmin

at the top ofyour script and just run the script as if you ran it as a Admin


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites

By doing this at the top of the screen, does that mean that after this is in there, it can run anything(double left click), and it would be the same as running it as and admin?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Yes, but you will still have to confirm the box, but you are running it as a Admin


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Then you need to turn off UAC in the User Account on Control Settings


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
Share on other sites

Okay, in that link I read it the window that pops up is the second window. I cant get the script to work in that window though

Share this post


Link to post
Share on other sites

in the link i read it

Share this post


Link to post
Share on other sites

Nevermind, thank you for the help. Closed(if i have to close it i dont know how, lol)

Share this post


Link to post
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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0