kor Posted April 19, 2011 Share Posted April 19, 2011 (edited) ; Global variables $sAdminUser = "testadmin" $sAdminPass = "testpassword" $sDomain = "AD" $sSysVolDir = "\\ad.domain.com\sysvol\ad.domain.com\scripts" msgbox(0, "it info", "running it info") ; Run ITInfo script RunAsWait($sAdminUser, $sDomain, $sAdminPass, 0, @AutoItExe & " " & $sSysVolDir & "\ITInfo\ITInfoLogin.au3", @ProgramFilesDir & "\AutoIt3", @SW_HIDE) msgbox(0, "student", "it info just ran") ; Run primary login script based on account type If StringRegExp(StringLeft(@UserName, 1), "\d") = 1 Or @UserName = "suser" Then ; if username begins with number or suser ; Account is a student user msgbox(0, "student", "im a student user") RunAsWait($sAdminUser, $sDomain, $sAdminPass, 0, @AutoItExe & " " & $sSysVolDir & "\StudentLogin.au3", @ProgramFilesDir & "\AutoIt3", @SW_HIDE) msgbox(0, "student", "student just ran") Exit Else ; Account is a staff user msgbox(0, "staff", "im a staff user") RunAsWait($sAdminUser, $sDomain, $sAdminPass, 0, @AutoItExe & " " & $sSysVolDir & "\StaffLogin.au3", @ProgramFilesDir & "\AutoIt3", @SW_HIDE) msgbox(0, "student", "staff just ran") Exit EndIf I do not understand why my script is running over and over again. As soon as the first msgbox pops up and I click ok.. and new instance of the program is spawned. Why? EDIT: It seems maybe it has something to do with the way it's being compiled. If I run the exact same code uncompiled on my XP machine everything works, but if I run an EXE compiled from a 2008R2 test VM the script runs over and over and over again. I've even tried making sure that I'm compiling on the 2008R2 machine as a x86 but same result. EDIT2: Ok, it seems as soon as I compile the script (regardless of what machine I compile it from) is where I am running into the issues. If I run the uncompiled script, it works normally. If I run the compiled EXE it runs over and over again. Exact same code! Edited April 19, 2011 by kor Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 19, 2011 Share Posted April 19, 2011 What did you expect from having the script run itself with @AutoItExe in the RunAsWait() calls? The first instance runs a second copy of @AutoItExe, and the second then runs a third instance, etc. Add some command line parameter handling so the script knows when it was called with parameters and should not launch itself again. 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...
BrewManNH Posted April 19, 2011 Share Posted April 19, 2011 I think you're looking for this: Form3: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...] Execute another script file from a compiled AutoIt3 Script File. Then you don't need to fileinstall another copy of AutoIT3.exe in your compiled file. 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...
kor Posted April 19, 2011 Author Share Posted April 19, 2011 I think you're looking for this:sample to get me started? I'm not sure how I proceed.I get now why its running over and over, but not how to stop it. Link to comment Share on other sites More sharing options...
BrewManNH Posted April 19, 2011 Share Posted April 19, 2011 Look at the commandline parameters in that quoted section, your script is trying to run another script when you have compiled it but you aren't using the command line parameter to do it. When it's not compiled, the RunAsWait line you have uses the Autoit3.exe program to run it, when it's compiled the @Autoitexe macro contains the name of your compiled program.@AutoItExe - The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script. 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...
kor Posted April 19, 2011 Author Share Posted April 19, 2011 (edited) Like this? RunAsWait($sAdminUser, $sDomain, $sAdminPass, 0, @AutoItExe & " /AutoIt3ExecuteScript " & $sSysVolDir & "\StudentLogin.au3", @ProgramFilesDir & "\AutoIt3", @SW_HIDE) ??? I'm not getting what you want me to change. Edited April 19, 2011 by kor Link to comment Share on other sites More sharing options...
BrewManNH Posted April 19, 2011 Share Posted April 19, 2011 That is what I was referring to, you need the command line parameter included if you're going to use your compiled script to run another script. 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...
kor Posted April 20, 2011 Author Share Posted April 20, 2011 (edited) Is my above change the correct code? EDIT: testing things it looks like that fixes it. Just want to make sure that is the right way to do it. Edited April 20, 2011 by kor 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