abhi Posted March 30, 2007 Share Posted March 30, 2007 Hello, I have a gui that accepts userid,password and commands (that need to be executed in a text area) I redirect the commands to a .bat file and I want to execute them using the credentials I have got from the user. How can I achieve the same using autoit? Any help is highly appreciated. Thanks Link to comment Share on other sites More sharing options...
BillLuvsU Posted March 30, 2007 Share Posted March 30, 2007 the funtion RunAs()... [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
Bert Posted March 30, 2007 Share Posted March 30, 2007 (edited) RunAsSet -------------------------------------------------------------------------------- Initialise a set of user credentials to use during Run and RunWait operations. 2000/XP or later ONLY. RunAsSet ( ["user", "domain", "password" [, options]] ) Parameters username [optional] The user name to use. domain [optional] The domain name to use. password [optional] The password to use. options [optional] 0 = do not load the user profile, 1 = (default) load the user profile, 2 = use for net credentials only Return Value Success: Returns 1--regardless of success. (If the login information was invalid, subsequent Run/RunWait commands will fail....) Failure: Returns 0 if the operating system does not support this function. Remarks This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator). The function only works on the 2000/XP (or later) platforms. NT4 users should install and use the SU command from the NT Resource Kit. The "Secondary Logon service" or "RunAs service" must not be disabled if you want this function to work. To unset the RunAs details, use the function with no parameters: RunAsSet(). Edited March 30, 2007 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
abhi Posted March 30, 2007 Author Share Posted March 30, 2007 Volly, I was considering the RunAsSet() call but I am not sure how I'd passing the actual cmd that needs to be executed Assuming $var contains my cmd, I do not see how I could pass it along to RunAsSet(). Thanks :"> RunAsSet -------------------------------------------------------------------------------- Initialise a set of user credentials to use during Run and RunWait operations. 2000/XP or later ONLY. RunAsSet ( ["user", "domain", "password" [, options]] ) Parameters username [optional] The user name to use. domain [optional] The domain name to use. password [optional] The password to use. options [optional] 0 = do not load the user profile, 1 = (default) load the user profile, 2 = use for net credentials only Return Value Success: Returns 1--regardless of success. (If the login information was invalid, subsequent Run/RunWait commands will fail....) Failure: Returns 0 if the operating system does not support this function. Remarks This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator). The function only works on the 2000/XP (or later) platforms. NT4 users should install and use the SU command from the NT Resource Kit. The "Secondary Logon service" or "RunAs service" must not be disabled if you want this function to work. To unset the RunAs details, use the function with no parameters: RunAsSet(). Link to comment Share on other sites More sharing options...
piccaso Posted March 30, 2007 Share Posted March 30, 2007 its explained in volly's post (remarks) but maybe you need an example ; Set the RunAs parameters to use local adminstrator account RunAsSet("Administrator", @Computername, "adminpassword") ; Run registry editor as admin RunWait("regedit.exe") ; Reset user's permissions RunAsSet() CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map Link to comment Share on other sites More sharing options...
abhi Posted March 30, 2007 Author Share Posted March 30, 2007 pardon my ignorance, but an exampl will definitely help its explained in volly's post (remarks) but maybe you need an example ; Set the RunAs parameters to use local adminstrator account RunAsSet("Administrator", @Computername, "adminpassword") ; Run registry editor as admin RunWait("regedit.exe") ; Reset user's permissions RunAsSet() Link to comment Share on other sites More sharing options...
abhi Posted March 30, 2007 Author Share Posted March 30, 2007 Got it! Thanks its explained in volly's post (remarks) but maybe you need an example ; Set the RunAs parameters to use local adminstrator account RunAsSet("Administrator", @Computername, "adminpassword") ; Run registry editor as admin RunWait("regedit.exe") ; Reset user's permissions RunAsSet() Link to comment Share on other sites More sharing options...
SpookMeister Posted March 30, 2007 Share Posted March 30, 2007 pardon my ignorance, but an exampl will definitely helpHe just gave you one. In his example 3 things happen1) The RunAsSet command is used to initiate rights of "Administrator"2) the run command is used to perform an action (while you are using the "Administrator" account's rights)3) The RunAsSet command is then run again (without parameters) to release the "Administators" permissons [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] 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