Sign in to follow this  
Followers 0
remin

Run .au3 script as Admin: no option in menu

17 posts in this topic

#1 ·  Posted (edited)

I created a script and I'm ready to launch it at windows start-up and want to do it as Admin in order to use the script also when a window has UAC enabled.

But...

- When I right click on the file there is No option "Run as Administrator" 

- I tried to add the file to task scheduler with elevated rights, but when I run the task it edits the file (in SciTE4)

- When I push down the CTRL & SHIFT key and click the script file, the same thing happens as running the task in task scheduler.

I'm the admin of the pc and I can run non autoit programs/scripts on above ways.

I tried to reinstall the autoit setup exe file running as administrator but it didn't resolve the problem.

What did I wrong?

How can I run the script with elevated rights in task scheduler?

ps: I'm running win8 64 bits, but installed autoit in 32bits mode.

Edited by remin

Share this post


Link to post
Share on other sites



There is a reason why you don't compile it as .exe?


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

I might be wrong here, but I don't believe you can run a scheduled task with higher rights than those with which it was created.

 

There is an option in the task scheduler, "Run with the highest privilege" or something like that


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites

There is an option in the task scheduler, "Run with the highest privilege" or something like that

 

Yes, I clicked that option in task scheduler.

Share this post


Link to post
Share on other sites

It may be that the highest available is that with which it was created.

 

Thank you for your reply.

Do you know how to change this?

I tried to copy the text of the script to an editor with elevated rights and saved it but that doesn't seems to work.

Share this post


Link to post
Share on other sites

There is a reason why you don't compile it as .exe?

 

I often change things in the script.

I would have to compile it every time.

btw.. 

my autoit = 32 bits.

my windows env = 64 bits.

Do I have to compile to 64 bits?

Share this post


Link to post
Share on other sites

Add

#requireadmin

to your script.

 

I added this to my script

but the file still is still edited  (in SciTE4) when I run the task in task scheduler.

Share this post


Link to post
Share on other sites

Can you explain exactly what you mean when you say " the file still is still edited  (in SciTE4) when I run the task in task scheduler."

 

Sorry,

I was a ahk user before and added my ahk script to the task scheduler in order to start the software under admin rights and without the UAC prompt:

http://www.techrepublic.com/blog/windows-and-office/run-uac-restricted-programs-without-the-uac-prompt/

That works well with ahk but not with au3 scripts.

At windows start-up it doesn't activate the script (as my old .ahk script) but it edits the file in SciTe4.

Share this post


Link to post
Share on other sites

remin,

You can change the default action for .au3 files from "Edit" to "Run" by using SciTEConfig. Look under the <Tools> menu (when you have a .au3 file open and select "SciTE Config" - the top option in the dialog which appears allows you to select the default action. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

remin,

You can change the default action for .au3 files from "Edit" to "Run" by using SciTEConfig. Look under the <Tools> menu (when you have a .au3 file open and select "SciTE Config" - the top option in the dialog which appears allows you to select the default action. :)

M23

 

Hi Melba :)

I checked it.

The default action for .au3 files was already set to "Edit" to "Run.

Remin

ps: when I double click on an .au3 file it runs the file.

      When I run the task (open the same file with elevated rights) in task scheduler it edits the file. 

Edited by remin

Share this post


Link to post
Share on other sites

You have to run AutoIt3 as admin and pass script as parameter I think.

 

Yes that did it. :)

I added 

"C:Program Files (x86)AutoIt3AutoIt3.exe"

to the task scheduler (Start a program --> Program/Script:)

and

d:scriptname.au3

in

Add arguments (optional)

And that opened the script with highest privileges.

Share this post


Link to post
Share on other sites

Clarifying: you don't need to run the script as admin from scheduled tasks. The script asks those rights by itself if it has #RequireAdmin.

When you run it from scheduled tasks one or two things happen: the admin account has Scite editor as the default action (you said you installed as admin and set that to "run"). Second: registry settings for the Admin account are not (fully) loaded, and the script runs on default standard settings no matter what you have set up...

Again, run it with any account and the #RequireAdmin will ask you for appropriate credentials. Or make a launcher, write RunAs (admin, pw, domain, script) to avoid writing the password.

Mind you that if you don't compile it, anyone will be able to read that password.


AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S

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

  • Similar Content

    • au3leecher
      By au3leecher
      Hellow everybody,
      I tryed to manipulate a game called "Assault Cube" which is a easy beginning in coding. I run the code but the wished value doesn't change, i don't understand why.
      The Pointers are fine, I checked that the pointers don't change every time while restart the game.
      My Code:
      <snip>
      _____________________________________________________________________________________________________________________________________________________________________________________________
      Checklist:
      The Offsets are 18C & 4
      In Cheat Engine: ("ac_client.exe"+0010F418) <- Pointer
      4 Bytes = 'dword'
       
    • rootx
      By rootx
      I need help to understand why the run function does not work, but if i use it directly inside cmd shell the command works. $where is the name of the jpg file
      ShellExecute(@ComSpec ," /k C:\Users\root\Desktop\test\exiftool.exe -p $FileName "&'"'&$where&'"'&" > "&'"'&@ScriptDir&"\out.txt"&'"',@ScriptDir);<----- work Run("C:\Users\root\Desktop\test\exiftool.exe -p $FileName "&$where&" > "&@ScriptDir&"\out.txt",@ScriptDir);<--- doesn't work I would use the run command!
      Thx
    • nacerbaaziz
      By nacerbaaziz
      Hello
      How are you
      I have a question, please.
      I've created a window and i need
      when i run the script if it detect an other copy from the same script was runing
       the script close the first copy Automatically and run a new copy
      I want an example to understand it
    • Nareshm
      By Nareshm
      Please Somebody Help me i am trying to create new script but, i don't know how to create it.

      I am Creating script like this :
      ; My script here [First Script]
      Check the internet connection, if internet connected then
      ; My Script here [Second Script]
      If internet not connected, wait for connect, after connected run my second script
      If Control id/windows/title matched do nothing and end/exit autoit script
      If Control id/windows/title not matched repeat my first and second script again until control id/windows/tittle not matched

      match with :
      >>>> Window <<<<
      Title:    PS :: Version - 2.8.0.0  - [PS Bill]
      Class:    WindowsForm734a
      Position:    -8, -8
      Size:    1382, 744
      Style:    0x17CD0000
      ExStyle:    0x00050100
      Handle:    0x0000000000130572
      >>>> Control <<<<
      Class:    WindowsForm734a
      Instance:    15
      ClassnameNN:    WindowsForm34a15
      Name:    BillPrint
      Advanced (Class):    [NAME:BillPrint]
      ID:    7875
      Text:    
      Position:    39, 310
      Size:    1221, 306
      ControlClick Coords:    745, 20
      Style:    0x56010000
      ExStyle:    0x00000000
      Handle:    0x00000000000C0468