Zeronic Posted October 26, 2012 Share Posted October 26, 2012 (edited) Hello, I've been using AutoIT for the last few month, but just got in to writing these full scripts. Normal I just have it call a batch file. This is my frist try at running the program with RunAsWait and it does work somewhat, but It copies the files over just fine and cleans up after itself but the exe files never run. RunAsWait("User", "Domain", "Password", 0, DirCreate("C:UsersAutoITAppDataLocalTempFlash")) RunAsWait("User", "Domain", "Password", 0, FileCopy("10.10.20.59ISPublicSoftwareuninstall_flash_player.exe", "C:UsersAutoITAppDataLocalTempFlashuninstall_flash_player.exe")) RunAsWait("User", "Domain", "Password", 0, FileCopy("10.10.20.59ISPublicSoftwareinstall_flash_player.exe", "C:UsersAutoITAppDataLocalTempFlashinstall_flash_player.exe")) RunAsWait("User", "Domain", "Password", 0, FileCopy("10.10.20.59ISPublicSoftwareinstall_flash_player_ax.exe", "C:UsersAutoITAppDataLocalTempFlashinstall_flash_player_ax.exe")) Sleep(2000) FileChangeDir("C:UsersAutoITAppDataLocalTempFlash") RunAsWait("User", "Domain", "Password", 0, "C:UsersAutoITAppDataLocalTempFlashuninstall_flash_player.exe") RunAsWait("User", "Domain", "Password", 0, "C:UsersAutoITAppDataLocalTempFlashinstall_flash_player.exe") RunAsWait("User", "Domain", "Password", 0, "C:UsersAutoITAppDataLocalTempFlashinstall_flash_player_ax.exe") RunAsWait("User", "Domain", "Password", 0, FileDelete("C:UsersAutoITAppDataLocalTempFlash*.exe")) RunAsWait("User", "Domain", "Password", 0, DirRemove("C:UsersAutoITAppDataLocalTempFlash")) Edited October 29, 2012 by Zeronic Link to comment Share on other sites More sharing options...
PhoenixXL Posted October 27, 2012 Share Posted October 27, 2012 Try with PSExec.exe refer to my signature [Runas System] to see an example My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 27, 2012 Share Posted October 27, 2012 Why would the OP need to use PSExec to run software on the local computer? That doesn't make a lot of sense. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Developers Jos Posted October 27, 2012 Developers Share Posted October 27, 2012 (edited) You probably need to specify a correct workdir for the Programs to run correctly. Where is your script shelled from? Edited October 27, 2012 by 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...
Zeronic Posted October 27, 2012 Author Share Posted October 27, 2012 Ok, I'll give that a try, setting the workdir to say that Temp folder, correct? I'll have complied it to an exe and shared on the network. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 28, 2012 Developers Share Posted October 28, 2012 (edited) The workdir is not the tempdir, but is the directory the shelled program initially "calls home", so this is the directory the program looks when you open a file without specifying a full path. It could be that this is not available anymore when shelled with different credentials, so in your case I would set it to: "C:UsersAutoITAppDataLocalTempFlash" Also check for the @error returned by the RunAsWait() Jos Edited October 28, 2012 by 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...
Zeronic Posted October 29, 2012 Author Share Posted October 29, 2012 (edited) RunAsWait("User", "Domain", "Password", 0, DirCreate("C:UsersAutoITAppDataLocalTempFlash")) RunAsWait("User", "Domain", "Password", 0, FileCopy("10.10.20.59ISPublicSoftwareuninstall_flash_player.exe", "C:UsersAutoITAppDataLocalTempFlashuninstall_flash_player.exe")) RunAsWait("User", "Domain", "Password", 0, FileCopy("10.10.20.59ISPublicSoftwareinstall_flash_player.exe", "C:UsersAutoITAppDataLocalTempFlashinstall_flash_player.exe")) RunAsWait("User", "Domain", "Password", 0, FileCopy("10.10.20.59ISPublicSoftwareinstall_flash_player_ax.exe", "C:UsersAutoITAppDataLocalTempFlashinstall_flash_player_ax.exe")) Sleep(2000) FileChangeDir("C:UsersAutoITAppDataLocalTempFlash") RunAsWait("User", "Domain", "Password", 0, "C:UsersAutoITAppDataLocalTempFlashuninstall_flash_player.exe", "C:UsersAutoITAppDataLocalTempFlash") RunAsWait("User", "Domain", "Password", 0, "install_flash_player.exe", "C:UsersAutoITAppDataLocalTempFlash") RunAsWait("User", "Domain", "Password", 0, "C:UsersAutoITAppDataLocalTempFlashinstall_flash_player_ax.exe") RunAsWait("User", "Domain", "Password", 0, FileDelete("C:UsersAutoITAppDataLocalTempFlash*.exe")) RunAsWait("User", "Domain", "Password", 0, DirRemove("C:UsersAutoITAppDataLocalTempFlash")) So I test try testing with both long and short pathing. Both tries returned 0. Edited October 29, 2012 by Zeronic Link to comment Share on other sites More sharing options...
Zeronic Posted October 31, 2012 Author Share Posted October 31, 2012 FileChangeDir(@TempDir) Msgbox (0, "Working Directory", @WorkingDir) RunAsWait( $User, $Domain, $Password, $LogFlag, DirCreate(@TempDir & "Flash")) RunAsWait( $User, $Domain, $Password, $LogFlag, FileCopy($Server & "Softwareuninstall_flash_player.exe", @TempDir & "Flashuninstall_flash_player.exe")) RunAsWait( $User, $Domain, $Password, $LogFlag, FileCopy($Server & "Softwareinstall_flash_player.exe", @TempDir & "Flashinstall_flash_player.exe")) RunAsWait( $User, $Domain, $Password, $LogFlag, FileCopy($Server & "Softwareinstall_flash_player_ax.exe", @TempDir & "Flashinstall_flash_player_ax.exe")) Sleep(2000) Msgbox (0, "Working Directory", @WorkingDir) RunAsWait( $User, $Domain, $Password, $LogFlag, @TempDir & "Flashuninstall_flash_player.exe", @TempDir & "Flash") RunAsWait( $User, $Domain, $Password, $LogFlag, "install_flash_player.exe", @TempDir & "Flash") RunAsWait( $User, $Domain, $Password, $LogFlag, @TempDir & "Flashinstall_flash_player_ax.exe", @TempDir & "Flash") Msgbox (0, "Working Directory", @WorkingDir) RunAsWait( $User, $Domain, $Password, $LogFlag, FileDelete(@TempDir & "Flash*.exe")) RunAsWait( $User, $Domain, $Password, $LogFlag, DirRemove(@TempDir & "Flash")) So I learned a bit more and update my script to reflect that, seem very odd that even when it places the files in the users temp folder that it still can't launch them. Is there away way to find out the cause of the error. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 31, 2012 Share Posted October 31, 2012 Does it actually copy the files to the right temp folder? Because @TempDir will be set to whoever is actually running the script, not the RunAs credentials. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Zeronic Posted October 31, 2012 Author Share Posted October 31, 2012 (edited) Yeah it does copy them over just fine. I wonder if I should remove that and only run the files as an admin, as the user can write file to their own temp folder and the location is shared to all domain users. Edited October 31, 2012 by Zeronic Link to comment Share on other sites More sharing options...
Zeronic Posted November 1, 2012 Author Share Posted November 1, 2012 Well I try running the command like this: RunAsWait($User, $Domain, $Password, $LogFlag, ShellExecute(@TempDir & "Flashuninstall_flash_player", "", @TempDir & "Flash", "Open")) An UAC box does pop up and ask for admin rights. So for whatever reason it will not start the exe with the admin rights. I can call a batch files as an admin and that runs but why not an exe file. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 1, 2012 Share Posted November 1, 2012 Why are you trying to ShellExecute and Run in the same line? Use RunAs if you want to run it, and get rid of the ShellExecute, not to mention unless the program is called "uninstall_flash_player" with no extension, it's probably not going to run anyways. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Zeronic Posted November 1, 2012 Author Share Posted November 1, 2012 (edited) Okay, I pulled out the ShellExecute and fixed my minor typo.RunAsWait($User, $Domain, $Password, $LogFlag, @TempDir & "Flashuninstall_flash_player.exe", @TempDir & "Flash")Still doesn't run the command, I see the user getting called in the event logs but nothing else. Edited November 1, 2012 by Zeronic Link to comment Share on other sites More sharing options...
BrewManNH Posted November 1, 2012 Share Posted November 1, 2012 As I stated before, the @TempDir macro is going to reference the currently logged on user's temp folder, is that where the file is? Do the RunAs credentials have access to that folder to run the program? Do you get any errors from the RunAsWait command? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Zeronic Posted November 1, 2012 Author Share Posted November 1, 2012 Yes, the files copy over and delete just fine to the users Temp Folder. The RunAs Credentials are those of a Domain Admin, but when I do pipe the error to a message box i get Return: 0. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=10.10.20.59ISPublicScriptsIconsflash.ico #AutoIt3Wrapper_Outfile=10.10.20.59ISPublicAutoITFlashUpdater3.exe #AutoIt3Wrapper_Res_Fileversion=0.0.0.10 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $User = "Admin" $Domain = "Domain" $Password = "Password" $Server = "10.10.20.59ISPublic" ;@ServerPath & "File Name" $LogFlag = 1 FileChangeDir(@TempDir) Msgbox ( 0, "Working Directory", @WorkingDir) DirCreate( @TempDir & "Flash") FileCopy( $Server & "Softwareuninstall_flash_player.exe", @TempDir & "Flashuninstall_flash_player.exe") FileCopy( $Server & "Softwareinstall_flash_player.exe", @TempDir & "Flashinstall_flash_player.exe") FileCopy( $Server & "Softwareinstall_flash_player_ax.exe", @TempDir & "Flashinstall_flash_player_ax.exe") Sleep( 2000) Msgbox ( 0, "Working Directory", @WorkingDir) RunAsWait( $User, $Domain, $Password, $LogFlag, @TempDir & "Flashuninstall_flash_player.exe", @TempDir & "Flash") MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & 'RunAsWait( $User, $Domain, $Password, $LogFlag, @TempDir & "Flashuninstall_flash_player.exe", @TempDir & "Flash")' & @lf & @lf & 'Return:' & @lf & RunAsWait( $User, $Domain, $Password, $LogFlag, @TempDir & "Flashuninstall_flash_player.exe", @TempDir & "Flash")) ;### Debug MSGBOX RunAsWait( $User, $Domain, $Password, $LogFlag, @TempDir & "Flashinstall_flash_player.exe", @TempDir & "Flash") RunAsWait( $User, $Domain, $Password, $LogFlag, @TempDir & "Flashinstall_flash_player_ax.exe", @TempDir & "Flash") Msgbox ( 0, "Working Directory", @WorkingDir) FileDelete( @TempDir & "Flash*.exe") DirRemove( @TempDir & "Flash") Link to comment Share on other sites More sharing options...
Zeronic Posted November 6, 2012 Author Share Posted November 6, 2012 Well I did manage to get my script to work, it instead calls files from the server. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=\\10.10.20.59\ISPublic\Scripts\Icons\flash.ico #AutoIt3Wrapper_Outfile=\\10.10.20.59\ISPublic\AutoIT\FlashUpdater9.exe #AutoIt3Wrapper_Res_Fileversion=0.0.0.14 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $User = "User" Local $Domain = "Domain" Local $Password = "Password" Local $Server = "\\10.10.20.59\ISPublic" ;@ServerPath & "File Name" Local $LogFlag = 0 Local $Software = "\Software" FileChangeDir($Server & $Software) Msgbox ( 0, "Working Directory", @WorkingDir) RunAsWait( $User, $Domain, $Password, $LogFlag, @ComSpec & " /C " & $Server & $Software & "\uninstall_flash_player.exe", $Server & $Software, @SW_ENABLE) RunAsWait( $User, $Domain, $Password, $LogFlag, @ComSpec & " /C " & $Server & $Software & "\install_flash_player.exe", $Server & $Software,@SW_ENABLE) RunAsWait( $User, $Domain, $Password, $LogFlag, @ComSpec & " /C " & $Server & $Software & "\install_flash_player_ax.exe", $Server & $Software, @SW_ENABLE) 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