obfuscatedv Posted January 15, 2014 Share Posted January 15, 2014 (edited) A bit stumped. Cannot get the script to exit with the proper exit codes. Ive tried changing around the exit code numbers, different commands, and still no luck. I'm trying to collect start page URL for a few users, and using exit codes since these URLs arent retrievable in other utilities. #RequireAdmin #NoTrayIcon $site1 = "google.com" $site2 = "yahoo.com" $reg = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page") $reg2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Secondary Start Pages") ;MsgBox(0, $reg, $reg2) Select Case StringInStr($reg, $site1) or StringInStr($reg2, $site1) Exit 270 Case StringInStr($reg, $site2) or StringInStr($reg2, $site2) Exit 271 EndSelect Edited January 15, 2014 by obfuscatedv Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 15, 2014 Moderators Share Posted January 15, 2014 obfuscatedv,Your code works fine for me if I modify the URLs - I also think you need to add a third Case: $site1 = "bbc" $site2 = "autoitscript" $reg = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page") $reg2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Secondary Start Pages") ;MsgBox(0, $reg, $reg2) Select Case StringInStr($reg, $site1) or StringInStr($reg2, $site1) Exit 270 Case StringInStr($reg, $site2) or StringInStr($reg2, $site2) Exit 271 Case Else Exit 272 EndSelectM23 obfuscatedv 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 You should show how you are retrieving exit codes, since that is the more likely problem. Well that and the fact that none of your case conditions are met. obfuscatedv 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
AdamUL Posted January 15, 2014 Share Posted January 15, 2014 Remember that some apps, like Task Scheduler, show the exit values as HEX. 270 = 0x10E 271 = 0x10F Adam obfuscatedv 1 Link to comment Share on other sites More sharing options...
obfuscatedv Posted January 15, 2014 Author Share Posted January 15, 2014 obfuscatedv, Your code works fine for me if I modify the URLs - I also think you need to add a third Case: $site1 = "bbc" $site2 = "autoitscript" $reg = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Start Page") $reg2 = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Secondary Start Pages") ;MsgBox(0, $reg, $reg2) Select Case StringInStr($reg, $site1) or StringInStr($reg2, $site1) Exit 270 Case StringInStr($reg, $site2) or StringInStr($reg2, $site2) Exit 271 Case Else Exit 272 EndSelect M23 I've tried adding a last case (just as you did above) if none of the conditions are met, but still no luck. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2014 Developers Share Posted January 15, 2014 (edited) So where/how are you checking this exit code? Jos Edited January 15, 2014 by Jos obfuscatedv 1 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...
obfuscatedv Posted January 15, 2014 Author Share Posted January 15, 2014 Remember that some apps, like Task Scheduler, show the exit values as HEX. 270 = 0x10E 271 = 0x10F Adam Thanks. Unfortunately, I have tried numerous exit codes to ensure none conflict. Link to comment Share on other sites More sharing options...
obfuscatedv Posted January 15, 2014 Author Share Posted January 15, 2014 (edited) So where/how are you checking this exit code? Jos Checking in SCCM reporting tool. The script completes successfully, however just not returning an exit code, which I've had no problem with in the past Edited January 15, 2014 by obfuscatedv Link to comment Share on other sites More sharing options...
AdamUL Posted January 15, 2014 Share Posted January 15, 2014 What are the codes returned? obfuscatedv 1 Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2014 Developers Share Posted January 15, 2014 Well, when you for example want to retrieve the %ERRORLEVEL% in a cmd session you need to compile the script as an console program. That can be done in aut2exe or "#AutoIt3Wrapper_Change2CUI=y" directive assuming you have installed the full installer of SciTE4AutoIt3. Jos obfuscatedv 1 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...
jdelaney Posted January 15, 2014 Share Posted January 15, 2014 (edited) Where test.exe (compiled through right click on script, pick 'Compile Script') is: If UBound($CmdLine)>1 Then Exit $CmdLine[1] Else Exit 999 EndIf Calling through command line like this: %comspec% /c test.exe 23 echo %errorlevel% output: 23 Maybe you aren't calling the exe properly? Edited January 15, 2014 by jdelaney obfuscatedv 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
obfuscatedv Posted January 15, 2014 Author Share Posted January 15, 2014 What are the codes returned? Doesnt return anything at all. Well, when you for example want to retrieve the %ERRORLEVEL% in a cmd session you need to compile the script as an console program. That can be done in aut2exe or "#AutoIt3Wrapper_Change2CUI=y" directive assuming you have installed the full installer of SciTE4AutoIt3. Jos Yep, I've compiled a couple different times Link to comment Share on other sites More sharing options...
jdelaney Posted January 15, 2014 Share Posted January 15, 2014 (edited) Or, use start /wait http://stackoverflow.com/questions/334879/how-do-i-get-the-application-exit-code-from-a-windows-command-line/11476681#11476681 Edited January 15, 2014 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 Try it using RunWait() AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jdelaney Posted January 15, 2014 Share Posted January 15, 2014 I don't think he is calling the exe from another script. But Poster can clarify how he is calling the exe. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
obfuscatedv Posted January 15, 2014 Author Share Posted January 15, 2014 I am not calling the exe from another script. Simply running this one script in itself. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2014 Developers Share Posted January 15, 2014 Where test.exe (compiled through right click on script, pick 'Compile Script') is: If UBound($CmdLine)>1 Then Exit $CmdLine[1] Else Exit 999 EndIf Calling through command line like this: %comspec% /c test.exe 23 echo %errorlevel% output: 23 Maybe you aren't calling the exe properly? You are right. Guess my memory let me down there why we put the CUI option in there. It was for the Consolwrite's to be shown in the CMD session. 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...
Solution jdelaney Posted January 15, 2014 Solution Share Posted January 15, 2014 So...do you still have an issue? I gave you two options of running the exe and waiting for completion, and returning the errorlevel (posts #11 and #13). You are probably just returning the errorlevel of 0, which is to say the process creates succesfully. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
obfuscatedv Posted January 15, 2014 Author Share Posted January 15, 2014 I have tried calling through the command line using errorlevel, in which 0 is returned. But even when changing my start URL as a test, it still does not accurately return these exit codes... Link to comment Share on other sites More sharing options...
jdelaney Posted January 15, 2014 Share Posted January 15, 2014 Show us HOW you are calling the exe through the command line. Can't read your mind/console. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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