Juvigy Posted July 21, 2008 Share Posted July 21, 2008 (edited) Can anyone help me with the part where the script would install (or do anything) as a different user where the user and the pass will be coded inside the script. Something like "runas" CMD command but with no password prompting the user. !0x Edited August 8, 2008 by Juvigy Link to comment Share on other sites More sharing options...
duckling78 Posted July 21, 2008 Share Posted July 21, 2008 The following will run your script as an administrator:#RequireAdminHere's a paste from the help file:#RequireAdmin --------------------------------------------------------------------------------Specifies that the current script requires full administrator rights to run.#RequireAdminParametersNone.RemarksThis function was primarily aimed at allowing AutoIt scripts to work correctly with Windows Vista User Account Control (UAC) (However, will also work on Windows 2000 and Windows XP).For more details see AutoIt on Windows Vista.As this function launch a new process, some functions as Consolewrite() cannot be captured (Scite will not display anything). Link to comment Share on other sites More sharing options...
Developers Jos Posted July 21, 2008 Developers Share Posted July 21, 2008 Look at RunAs() in the Helpfile muttley SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Juvigy Posted July 25, 2008 Author Share Posted July 25, 2008 Require admin doesnt work for me. It just requires the user that runs the script to have admin rights. I found that "RunAsSet" will do the trick , but it works only for the "run" functions. It wont work for the "ShellExecute" or other such functions. Is there any way that the whole script to have admin rights and not just the calls of the "run" functions? Link to comment Share on other sites More sharing options...
Distrophy Posted July 25, 2008 Share Posted July 25, 2008 If not IsAdmin() Then RunAs("user","domain","pass",0,@ScriptName,@ScriptDir) Exit EndIfThat will rerun your executable with credentials. I have only tested with executables but i dont think it will run the .au3. Link to comment Share on other sites More sharing options...
Juvigy Posted July 25, 2008 Author Share Posted July 25, 2008 If not IsAdmin() Then RunAs("user","domain","pass",0,@ScriptName,@ScriptDir) Exit EndIf That will rerun your executable with credentials. I have only tested with executables but i dont think it will run the .au3. I already found that , but it works only for "RunAs" function. I need more. For example ShellExecute or call dll's with admin credentials. And running the whole script/ ".exe" file with admin credentials / credentials i specify in the script. Link to comment Share on other sites More sharing options...
Distrophy Posted July 25, 2008 Share Posted July 25, 2008 I already found that , but it works only for "RunAs" function. I need more. For example ShellExecute or call dll's with admin credentials. And running the whole script/ ".exe" file with admin credentials / credentials i specify in the script.Right, you want to re-run your whole script as an admin if the current user isnt one, correct?That code will do that. it is checking to see whether the current user is an admin, if they are not, the script re-runs itself using admin credentials.the @ScriptName,@ScriptDir are telling autoit to rerun itself using the login provided.I believe the code will only work once you have compiled your script to an exe. Link to comment Share on other sites More sharing options...
Juvigy Posted July 28, 2008 Author Share Posted July 28, 2008 Cant find this functions in my AutoIt , or in the help file. I only find RunAsSet . I have V3 . Link to comment Share on other sites More sharing options...
TPlanet Posted July 28, 2008 Share Posted July 28, 2008 Hi, You have to run this script that will relaunch this script as admin, then do all you need; CODE If Not IsAdmin() Then RunAsSet("Administrator",@ComputerName,"adminpassword") FileCopy(@AutoItExe, "c:\TempInst\",8) ;if runned from network, need to copy the .exe on the wks as wks admin has't drive mapped ;make sure to copy it somewhere user has privileges to write and create folder Runwait("c:\TempInst\" & @ScriptName , "c:\TempInst\") DirRemove("c:\TempInst",1) RunAsSet() Exit EndIf ; your code here, all will be runned as admin ShellExecute() run() Exit Have fun! TP Link to comment Share on other sites More sharing options...
Developers Jos Posted July 28, 2008 Developers Share Posted July 28, 2008 Cant find this functions in my AutoIt , or in the help file. I only find RunAsSet . I have V3 .... use the latest AutoIt3 version for the RunAs(). RunAsSet() is obsolete since the latest release.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jp10558 Posted July 29, 2008 Share Posted July 29, 2008 ... use the latest AutoIt3 version for the RunAs(). RunAsSet() is obsolete since the latest release.JosWas there any explanation why they changed from RunAsSet() to RunAs()? It seems to then make you type in the info many more times if you need to do several tasks as a different user. Link to comment Share on other sites More sharing options...
Juvigy Posted July 30, 2008 Author Share Posted July 30, 2008 Thank you guys. It works perfectly now. Link to comment Share on other sites More sharing options...
jstump1 Posted August 9, 2008 Share Posted August 9, 2008 Sorry this reply is late - Depending on what you are doing psexec (part of pstools from microsoft) may be useful for launching scripts with elevated priviledges.It allows you to run the script against many hosts if necessaryIt does not require that a user be logged onIt is a great tool to use in conjunction with AutoIT!For requirements see:http://forum.sysinternals.com/forum_posts....D=3748&PN=1http://forum.sysinternals.com/forum_posts.asp?TID=9139Stumppc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now