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

    • Eggsplorer
      By Eggsplorer
      Hi,
      Ich hab ein Script für Windows Updates, dass nach dem OOBE aufgerufen werden soll. Run/RunOnce ist daher nicht möglich.
      Stattdessen möchte ich das Script in den Autostart schreiben lasse. Wenn die OOBE beendet wird und der Administrator angemeldet wird, soll das Update-Script einmalig aufgerufen werden und sich anschl. selbst löschen.
      Lang rede, kurzer Sinn:
      Wie kann ich folgendes Script in den Autostart schreiben?
      RunWait(@ComSpec & " /c " & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\UA\Scripts\win-updates.ps1 -MaxUpdatesPerCycle 100 -RestartRequired 1", "") Ich würde ungern eine BAT oder EXE reinkopieren, da ich es unsauber finde. Die müsste ja auch zusätzlich irgendwo liegen.
      Danke
      Eggsplorer
    • BlazerV60
      By BlazerV60
      Hello all,
      I've written the code below which launches chrome in incognito mode and then proceeds to go to the autoit website.
      From my understanding, the Run() command is also supposed to output the PID number related to the application that got launched from the Run command.
      However when I run the below lines, it outputs a PID number that is different from the newly launched chrome browser's PID number, does anyone know why and possibly explain how I could retrieve the accurate PID number associated with the newly launched browser?
      Global $iPid = Run(@ComSpec & ' /c start chrome.exe https://www.autoitscript.com/forum/ -incognito' ,"", "") msgbox(0,"",$iPid) Thank you,
      Brian
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I worked a bit on a little project of mine, and I managed to do what I was trying to do, or, automate a quiz in AutoIt.
      Now, everything works fine but, in order to achieve what I'm trying to achive, I'd like to make this script run faster.
      I'll attach a portion of the code in order to let you understand what my script does.
      $objIE_h1 = _IETagNameGetCollection($objIE, "h1") ; Take the text of the answer If @error Then ConsoleWrite("Errore durante la lettura degli h1 nella pagina. - Errore: " & @error & @CRLF) Else For $objElement In $objIE_h1 $strInnerText = $objElement.innerText Next Select Case StringInStr($strInnerText, "QUESTION") ; Here is the question ; PS4 PRO $objSpans = _IETagNameGetCollection($objIE, "span") ; Answers are stored here For $objElement In $objSpans If $i >= 4 Then $strAnswer = $objElement.innerText ; Take the text of the answer n° 0, 1, 2, 3 If StringInStr($strAnswer, "CORRECT ANSWER") Then ; If I match the correct answer, then, I have to click on the input with answer id = answer_i $j = $i - 4 $objInput = _IEGetObjById($objIE, "answer_" & $j) If @error Then ConsoleWrite("Errore durante la lettura della risposta #" & $i & " - Errore: " & @error & @CRLF) Else _IEAction($objInput, "click") If @error Then ConsoleWrite("Errore durante il click sull'elemento. - Errore: " & @error) Else ConsoleWrite($j & ") Risposta: " & $strAnswer & @CRLF) ExitLoop EndIf EndIf EndIf $i+=1 Else $i+=1 EndIf Next $i = 0 $j = 0 This is what my script does.
      Questions are 20, in which I have 15 multiple choice question, 2 images ( on which I use _IEImgClick() ), and 3 text inputs ( a simple send with the text I have to enter ).
      How can I make all of these, faster?
      If I reach this goal, I've probably done one of my best goals in life, and I'd like to share my happiness with you, giving a huge donation to this fantastic community!
      Thanks for your help
    • 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