Jump to content

Script wont exit with Exit code


Go to solution Solved by jdelaney,

Recommended Posts

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 by obfuscatedv
Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Developers

So where/how are you checking this exit code?

Jos

Edited 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

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 by obfuscatedv
Link to comment
Share on other sites

  • Developers

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

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

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 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

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

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

  • Developers

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

  • Solution

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...