ibanezfreak4 Posted February 4, 2010 Share Posted February 4, 2010 (edited) Hey there, I am brand new to the forum. I have done some significant searching to see if anyone can re-create my particular issue.What I have scripted in AutoIT is a program that points to a slew of .CMD files to launch application installs. What is happening sometimes is that the X: drive mapping does not always work if the support specialist navigates to the server where the AutoIT application is hosted. Seems that if Windows explorer is already navigated to the same location, it will not map a drive to that location. A button would be the perfect solution.What I am trying to accomplish is creating a button that maps the X: drive to the server using a RunAs command to run as the local Administrator (the work around is the right click the app and Run As admin). These are my attempts so far:As the application is launched, not always working:DriveMapAdd("X:", "\\Server\Store", 0, "Domain\UserName", "password")SplashTextOn("Software Installer", "POST RIS Software Installer.", 350, 30, 200, 200, 0, "", 12)Button to be launched: ;$MapDrive = GUICtrlCreateButton("Map Drive", 340, 392, 73, 33, 0) ;GUICtrlSetFont(-1, 8.5, 800, 0, "MS Sans Serif") ;GUICtrlSetColor(-1, 0x000080)This is in my While 1 script: ;Case $MapDrive ;MapDrive()This is the function that is not working properly (have also tried RunAsSet): ;Func MapDrive() ;RUNAS("Administrator", "%COMPUTERNAME%", "%COMPUTERNAME%12345", 0, ;DriveMapAdd("X:", "\\Server\Store") ;EndFuncAdditionally, our local administrator password is a numbering convention after the computer name. How is that scripted?Any and all help would be much appreciated, thank you! Edited February 4, 2010 by ibanezfreak4 Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 4, 2010 Share Posted February 4, 2010 (edited) That environment variable is only going to expand if you have Opt("ExpandEnvStrings", 1). Just use the AutoIt macro instead. Use RunAsWait() so you can get the return code. Also, you can't pass RunAs() an AutoIt function, so use NET USE: $iRET = RunAsWait("Administrator", @ComputerName, @ComputerName & "12345", 0, "NET USE X: \\Server\Store") P.S. Technically, you can run a native AutoIt function with this (see help file): AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line" Edited February 4, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
i386 Posted February 4, 2010 Share Posted February 4, 2010 As the application is launched, not always working: DriveMapAdd("X:", "\\Server\Store", 0, "Domain\UserName", "password")SplashTextOn("Software Installer", "POST RIS Software Installer.", 350, 30, 200, 200, 0, "", 12)This is the function that is not working properly (have also tried RunAsSet): ;Func MapDrive() ;RUNAS("Administrator", "%COMPUTERNAME%", "%COMPUTERNAME%12345", 0, ;DriveMapAdd("X:", "\\Server\Store", "Domain\UserName", "password") ;EndFunc I may be wrong, but I think to fix your current function you would have to script it like this: Func MapDrive() DriveMapAdd("X:", "\\Server\Store", 0, "Domain\UserName", "password") RunAs("Administrator", %COMPUTERNAME%, %COMPUTERNAME% & "12345", 0, "your_program_location") EndFunc Then, eliminate the DriveMapAdd at the beginning of your script, because once you click the Map Drive button on your GUI, it will map the drive for you then. Also, make sure that you remove your semi-colons as well that are before each line, otherwise the compiler will skip those lines all together, As for your numbering convention for your password, I am not sure exactly what you mean. Spoiler "...Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like.My crime is that of outsmarting you, something that you will never forgive me for." --The Mentor "Mess with the best, die like the rest!!" -Hackers "This above all to thine own self be true." -William Shakespeare "Corruption is only as corrupted as the individual makes it out to be." -i386 Link to comment Share on other sites More sharing options...
ibanezfreak4 Posted February 4, 2010 Author Share Posted February 4, 2010 I may be wrong, but I think to fix your current function you would have to script it like this: Func MapDrive() DriveMapAdd("X:", "\\Server\Store", 0, "Domain\UserName", "password") RunAs("Administrator", %COMPUTERNAME%, %COMPUTERNAME% & "12345", 0, "your_program_location") EndFunc Then, eliminate the DriveMapAdd at the beginning of your script, because once you click the Map Drive button on your GUI, it will map the drive for you then. Also, make sure that you remove your semi-colons as well that are before each line, otherwise the compiler will skip those lines all together, As for your numbering convention for your password, I am not sure exactly what you mean. Thanks for the replies, I will give these a try. The numbering convention is the name of the machine PLUS 12345. So if your PC name was AUTOIT the local admin password would be AUTOIT12345. Thanks again. Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 4, 2010 Share Posted February 4, 2010 The numbering convention is the name of the machine PLUS 12345. So if your PC name was AUTOIT the local admin password would be AUTOIT12345.You know that's a phenomenally BAD idea, right...? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ibanezfreak4 Posted February 4, 2010 Author Share Posted February 4, 2010 You know that's a phenomenally BAD idea, right...? Something like that... I'm not in charge of the IT Security portion. We still have local admin rights to all our users... Kinda another phenomenally TERRIBLE idea.So... YES, I know exactly what you're saying. Link to comment Share on other sites More sharing options...
ibanezfreak4 Posted February 4, 2010 Author Share Posted February 4, 2010 (edited) That environment variable is only going to expand if you have Opt("ExpandEnvStrings", 1). Just use the AutoIt macro instead. Use RunAsWait() so you can get the return code. Also, you can't pass RunAs() an AutoIt function, so use NET USE: $iRET = RunAsWait("Administrator", @ComputerName, @ComputerName & "12345", 0, "NET USE X: \\Server\Store") P.S. Technically, you can run a native AutoIt function with this (see help file): AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line" I tried this approach to map through NET USE, but it prompts for a user name for the server? Attached picture. Should it be scripted a little differently? Edited February 4, 2010 by ibanezfreak4 Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 4, 2010 Share Posted February 4, 2010 Try adding the credentials to the NET USE command line: $iRET = RunAsWait("Administrator", @ComputerName, @ComputerName & "12345", 0, "NET USE X: \\Server\Store " & @ComputerName & "12345 /u:" & @ComputerName & "\Administrator") Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ibanezfreak4 Posted February 4, 2010 Author Share Posted February 4, 2010 That "partially" worked. I didn't necessarily read into what the error was actually giving me... I don't think this button is going to perform what we need it to. What I really need is for the entire application to re-launch and be "RunAs". This sounds like it is too complex to complete. Maybe I have this button prompt the support specialist for their ID and PW? Is that possible with a RunAsWait? Or is that another function? Thanks. 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