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

    • lenclstr746
      By lenclstr746
      Hi guys,
      Some functions of my script are running slowly. Very slow. What is the reason?
      My Code:
      <snip>
    • HariKara
      By HariKara
      Hi AutoIters!
       
      Im trying to launch a .exe file that is nested within the program files (x86) folder structure. i have already used the standard RunAs Syntax and found that it fails to launch the application. I have switched to Run and that seems to work. My issue is I have to use RunAs as the applicaton would need to run under a completely different account. The Current logged in user is a Local User on the machine, however, the application must be run as a domain user. The Machine is domain connected.
       
       have tried the following:
      RunAs("username","logonpassword", $RUN_LOGON_PROFILE, "D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") The above fails to launch, there are no errors or syntax issues, it just does nothing when the variables are replaced for the correct values.
      I did the same using the Run command
      Run("D:\Program Files (x86)\Vendor\Application Name\Exe Location\Executable.exe") That seems to work fine, but runs in local user context. Any thoughts? Could it be a local Machine rights issue? Or have i missed something glaring in my script
    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • nacerbaaziz
      By nacerbaaziz
      Hello
      i have searched a lot about how to run external programs with the administrator privileges without the script running with administrator privileges using autoit
      But all my attempts failed
      Finally, today I found the VBS function doing this task
      I immediately transferred it to our beloved language (autoit) and i decided to share it with you
      i hope you like it
      This is a simple example about how to use the function

      runAsAdmin("cmd.exe", "/c @echo off & cls & echo test & pause", "c:\", @sw_show)
      this is the function

      func runAsAdmin($program, $parameters = "", $workingDir = @workingDir, $show = "") local $oShell = OBJCreate("Shell.Application") if isOBJ($oShell) then local $result = $oShell.ShellExecute($program, $parameters, $workingDir, "runas", $show) else $result = false endIf return $result endFunc
       
    • nacerbaaziz
      By nacerbaaziz
      Hello all
      I have a question please
      Is there a way to request the script for administrator privileges if a particular condition is met??
      example
      local $path = RegRead("HKEY_CURRENT_USER\Software\test", "fullpath")
      if $fullPath = @scriptFullPath then
      Request for administrator privileges
      main()
      else
      main()
      endIf
      I hope to find a solution here
      Greetings to all
×