Jump to content
Sign in to follow this  
remin

Run .au3 script as Admin: no option in menu

Recommended Posts

remin

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
Terenz

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
Terenz

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
remin

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
remin

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
remin

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
remin

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
remin

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
Melba23

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
remin

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
remin

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
Ktulu789

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  

  • Similar Content

    • rudi
      By rudi
      Hello,
      for a script to display PDF files I'd like to simply use the default program for PDF files, so I used "ShellExecute(<pdf-file-full-path>)" to open these files.
       
      The result for *SOME* of the workstations is, that the Adobe Reader starts up with asking for its language. (English/German). When starting AcroRd32.exe through "ShellExecute()", this "choose your language" dialog is showing up *ALWAYS*.
       
      Just to have mentioned it: Process Explorer is presenting this command line, it looks the same for both, PCs with and without that question "Choose Language? [English|German]"
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" --channel=4680.0.860715181 --type=renderer "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf"  
      The next approach I thought of was to use Foxit Portable (instead of Acrord32.exe), started from a Network Drive, but it's starting up ugly slowly...
      So I tried to "Run()" instead to "ShellExecute()" the Adobe Reader. Now the result looks more stange, the "select your language" dialog shows up every now and then, but not always for the Win7 installations affected.
       
      If I place a "msgbox()" just in front of the "run()" command, it seems never to show this "select your language" dialog.
      If I take out this MsgBox() the "select your language" dialog shows up sometimes.
      When I "ClipPut()" the run command prior the "Run()" and paste that one to a CMD box, then it seems to *NEVER* happen, that this "select your language" dialog shows up.
       
      "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe" "\\pc0009\Y_DRV_H\Daten\TIF\08\32\G000110832_Freigegeben.idw.pdf" $AcroRead='"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"' $PDF='"Y:\Temp\DRV_H\Daten\TIF\33\85\153385_Freigegeben.dwg.pdf"' MsgBox(0,"Values",$AcroRead & @CRLF & $PDF,1) $MyCommand=$AcroRead & " " & $PDF ClipPut($MyCommand) Run($MyCommand)  
      It looks like, that this "--channel=... --type=renderer" parameters are always fact for the AcroRd32.exe instance, that is opening the PDF to be displayed. The Instance opening the "PDF Display GUI" seems to always be a child process of another AcroRd32.exe process.
       
      Any clue, what's going on "backstage" here? How to avoid this "Choose your language" dialog? Or maybe someone can mention a different "portable" PDF viewer, I could use for this purpose?  
      Any suggestions appreciated, regards, Rudi.
    • nacerbaaziz
      By nacerbaaziz
      Hello all
      I found this function in the Internet
      It is to play audio files from  the compiled script
      I did not understand just one thing on this function
      func play($name, $wait = 0) local Const $SND_RESOURCE = 0x00040004 local Const $SND_ASYNC = 1 ; Play the file - the script will pause as it sounds if $wait = 0 then DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", BitOR($SND_RESOURCE, $SND_ASYNC)) else DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", $SND_RESOURCE) endIf return 1 endFunc What I did not understand was this variable
      local Const $SND_RESOURCE = 0x00040004 I know that this variable is contains the resource name
      But what if I want to change the name of the resource what i'll do?
      can i do that?
      Thanks in advance
       
    • krasnoshtan
      By krasnoshtan
      Hello forum users!
      At some point I had a need to restart my script. Is it possible to do this with autoit or do I need to connect additional scripts like .cmd or .bat?
      For example: i have only script.au3 and it's running. Wich code shoud i use to exit from the script and start it again?
    • tintin92
      By tintin92
      Hello,

      How can I automatically download a list of zip files, like the ones in the quote, using a AutoIt script?
      Is it possible with AutoIt script?
       
    • rkr
      By rkr
      Hi, I have a software which has a 'run file'-ie; when i double click on that file, the input file of the software is run by the software. I wish to double click/execute this run file using autoit. how do i achieve this. i opened the software and it shows the input file and run file in same folder, i will put my autoitscript file too in same location. how do i simulate double clicking the run file (using its file name, say - abc.run ). I entered the following lines to make software window active - it became active, dont know how to go forward
      Winactivate("program title")
      winwaitactivate("program title")
      controlclick("program title","abc.run",1000,"primary",2) ; 1000 is ctrl id
×