Jump to content
Sign in to follow this  
obfuscatedv

Script wont exit with Exit code

Recommended Posts

obfuscatedv

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

Share this post


Link to post
Share on other sites
Melba23

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
  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
AdamUL

Remember that some apps, like Task Scheduler, show the exit values as HEX.

270 = 0x10E

271 = 0x10F

 

Adam

  • Like 1

Share this post


Link to post
Share on other sites
obfuscatedv

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.

Share this post


Link to post
Share on other sites
obfuscatedv

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. 

Share this post


Link to post
Share on other sites
obfuscatedv

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

Share this post


Link to post
Share on other sites
Jos

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

  • Like 1

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jdelaney

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
  • Like 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.

Share this post


Link to post
Share on other sites
obfuscatedv

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
obfuscatedv

I am not calling the exe from another script. Simply running this one script in itself.

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
jdelaney

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.

Share this post


Link to post
Share on other sites
obfuscatedv

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.