darkleton Posted June 13, 2007 Share Posted June 13, 2007 Hi, I have a script to change users passwords via active directory on a domain. I want to be able to have the .exe on my pen drive so i can use this wherever and whenever. the thing is, to change the passwords, the program needs to be run with my credentials. if a person is already logged on and i plug in my usb stick i want to be able to run the exe, it prompts for user/pass etc and uses that as the runas command so basically it will: double click exe asks for username/password then runs the main script i know i can use runasset, but then that only affects run and runwait commands, i want the whole script to be run with my credentials, not just one function. is there a way of doing this? i'm sorry if i didn't explain myself too well. thanks Link to comment Share on other sites More sharing options...
/dev/null Posted June 13, 2007 Share Posted June 13, 2007 (edited) i know i can use runasset, but then that only affects run and runwait commands, i want the whole script to be run with my credentials, not just one function.is there a way of doing this? i'm sorry if i didn't explain myself too well.see help file for RunAsSet(). Similar solutions have been posted on the forum like this one: http://www.autoitscript.com/forum/index.ph...st&p=339615 Edited June 13, 2007 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
darkleton Posted June 13, 2007 Author Share Posted June 13, 2007 i have checked the help file. the RunAsSet help says: Initialise a set of user credentials to use during Run and RunWait operations I dont want them initialised during run and runwait commands, i want the credentials to be required before the program is run, rather than when a seperate external executable is run. Link to comment Share on other sites More sharing options...
/dev/null Posted June 13, 2007 Share Posted June 13, 2007 i have checked the help file. the RunAsSet help says:Initialise a set of user credentials to use during Run and RunWait operationsI dont want them initialised during run and runwait commands, i want the credentials to be required before the program is run, rather than when a seperate external executable is run.no, I'm talking about the sample script ! __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
darkleton Posted June 13, 2007 Author Share Posted June 13, 2007 yeah, i see that, but if i set the runasset details to my own, this will only come into effect when subsequent run commands are used, is that correct? my script calls no external programs, so i have no run commands, so the credentials aren't being used. With the example, it lets you set user/pass and then uses that for ; Run registry editor as admin RunWait("regedit.exe") but if i'm not calling any external .exes using the Run command, doesn't that render the RunAsSet command useless? I want my whole script to be run with my credentials, regardless who is logged on, not just one external exe Only way I can see it is to compile the first part as an exe, then make another script using RunAsSet that calls the original script exe, that way using my credentials. WOuld that work? Link to comment Share on other sites More sharing options...
bhoar Posted June 13, 2007 Share Posted June 13, 2007 You could write your program to check the current user context and if it isn't high enough, runasset and then execute itself again. You'll probably want to also check the number of times your process shows up in the process table and limit the forking to 2-4 times max, to prevent a sorcerer's apprentice situation... Link to comment Share on other sites More sharing options...
BananaFredSoft Posted June 13, 2007 Share Posted June 13, 2007 You could use @UNAME and _IsAdmin () to check who is using it.Hi,I have a script to change users passwords via active directory on a domain. I want to be able to have the .exe on my pen drive so i can use this wherever and whenever. the thing is, to change the passwords, the program needs to be run with my credentials.if a person is already logged on and i plug in my usb stick i want to be able to run the exe, it prompts for user/pass etc and uses that as the runas commandso basically it will:double click exeasks for username/passwordthen runs the main script i know i can use runasset, but then that only affects run and runwait commands, i want the whole script to be run with my credentials, not just one function.is there a way of doing this? i'm sorry if i didn't explain myself too well.thanks -ColinSite:www.bananafredsoft.comStuff:Simple Text Editor - MediaPlayer - Animator - BananaDB - BananaNotes - Chatta - Filesearch - Excuse GeneratorMy YouTube channel:http://www.youtube.com/user/colipat Link to comment Share on other sites More sharing options...
/dev/null Posted June 13, 2007 Share Posted June 13, 2007 yeah, i see that, but if i set the runasset details to my own, this will only come into effect when subsequent run commands are used, is that correct? No, not for the sample in the help file. It re-runs the AutoIT script with "admin" privileges! You should also have looked at the link I posted, which gives a complete and working example! ; This example will rerun itself with admin rights on using a local account ; Note on Vista this may not work as even though the user is admin it may ; not be elevated even after the RunAs call. In that case use #RequireAdmin ; at the top of the script. ; Are we already admin? If Not IsAdmin() Then RunAsSet('USER', @Computername, 'PASSWORD') Run('"' & @AutoItExe & '"' & ' "' & @ScriptFullPath & '"', @WorkingDir) Exit EndIf MsgBox(0, 'Message', 'Now running with admin rights.') __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
MrBeatnik Posted June 13, 2007 Share Posted June 13, 2007 You could have a batch file calling the autoitscript using the windows RUNAS command.But the example above is correct, and a nice round package.When you run the example, it will re-run itself as admin (but also pass a "1" so that it doesn't do a re-run recursive loop).Therefore the entire script will run as the admin, and not just the run functions within.Just don't lose the pen or let any malicious program copy the contents! Please correct me if I am wrong in any of my posts. I like learning from my mistakes too. Link to comment Share on other sites More sharing options...
Airwolf Posted June 19, 2007 Share Posted June 19, 2007 Hi, I have a script to change users passwords via active directory on a domain. I want to be able to have the .exe on my pen drive so i can use this wherever and whenever. the thing is, to change the passwords, the program needs to be run with my credentials. if a person is already logged on and i plug in my usb stick i want to be able to run the exe, it prompts for user/pass etc and uses that as the runas command so basically it will: double click exe asks for username/password then runs the main script i know i can use runasset, but then that only affects run and runwait commands, i want the whole script to be run with my credentials, not just one function. is there a way of doing this? i'm sorry if i didn't explain myself too well. thanks Is this what you are looking for? $username = InputBox("Username","Username:","","") $password = InputBox("Password","Password:","","*") RunAsSet($username,@ComputerName,$password) Run("yourscript.exe") RunAsSet() Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt 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