Search the Community
Showing results for tags 'rights'.
Found 2 results
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.
Hey guys, I just came across this thread; Where the poster asked how to run an internal function with admin rights. As far as I am aware, there has never been a script example of this. As is debated for the next 10 or so posts, this is not actually running the function with admin rights, it re-runs the file with admin credentials, runs the function with the parameter "a" (This can be changed) and then runs the function, which checks that the user is admin. What happens if they are admin, and what happens if they are not admin can, ofcourse, be changed. So I'll cut the chit-chat, here is the example: For $Repeat = 1 To $CmdLine;The $cmdline array is automatically set by autoit. It contains any parameters given to the program when it is run. ;Hold Shift and press F8 in scite to set parameters. Enter "a" into the first box, without quotes. MsgBox(0,"",$CmdLine[$Repeat]) ;For debug reasons - shows you what the current parameter is. If $CmdLine[$Repeat] = "a" Then ;Checks to see that the current parameter is "a" _AdminFunction() EndIf Next If @Compiled = 1 Then RunAs(InputBox("Username", "Insert the username of the administrator", "Administrator"), "", InputBox("Password", "Insert the password of the admin account.", ""), 0, FileGetShortName(@ScriptFullPath) & " a");Runs the compiled script with the a parameter Else RunAs(InputBox("Username", "Insert the username of the administrator", "Administrator"), "", InputBox("Password", "Insert the password of the admin account.", ""), 0, FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath)& " a");Runs the uncompiled script with the a parameter EndIf Func _AdminFunction() If IsAdmin() Then;Ensures that the current user is admin as a normal user could run the program with the parameter set (if they have access to the code or try the parameter by pure chance to see what it does) MsgBox(0,"","Running Function as Admin") ;You can place your required script here. Else MsgBox(0,"","Running Function as Normal User. Function will not attempt") ;Function is not run be an administrator and so it will exit. EndIf Exit EndFuncI have tried this from a guest account on my computer (with and without credentials) and it has worked perfectly. I also tried running it as both compiled, and uncompiled, and again, it worked exactly as expected. It might not be something that people will use all the time, but it's here for anybody who does need it, and I am quite happy with it. A few other ideas I have had since writing this scipt, as to how it may communicate involve writing to the STDOUT stream at the end of the function, and having the calling part of the script read it, or using mailslot which is inter-script communication.