Page 1 of 1 1
Topic Options
#205462 - 2012-07-16 10:16 AM Forcing Error Codes
SMAndy Offline
Just in Town

Registered: 2012-07-10
Posts: 4
Loc: UK
Hi All.

I use Kix scripts to push out software, using SCCM. These scripts are perfect, because we can run them on any PC as long as we link to the correct files. Currently, most of our installs are something along the lines of...
1. message box saying "this is going to be installed. Do you want it? Click Yes or No."
2. script jumps to section relevant to their choice.
3. script either exits, or runs the install.

Now I want to use a script like this in a different way. It's being run before an install, but the script itself can't point at the install (different installation process). This means I essentially need it to give an error code at a certain point in the script, so the installation fails when someone clicks No. The reason being that if the script ends, for whatever reason, it'll jump to the next bit, which is an installation.

Does anyone know how I can force a script to give me an error code? Even if it's something as simple as a piece of code that makes no sense, and will fail with an error code... The code itself doesn't need to be something specific, as long as the system will read it as "Fail."

Thanks,

Andy.

Top
#205463 - 2012-07-16 10:52 AM Re: Forcing Error Codes [Re: SMAndy]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Hi Andy,

You can exit a script and set the exit code like shown below.

 Code:
if exist("c:\something.txt")
  ?"Found something.txt"
  Exit 0
else
  ?"Did not find something.txt"
  Exit 2
endif
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#205464 - 2012-07-16 11:01 AM Re: Forcing Error Codes [Re: Mart]
SMAndy Offline
Just in Town

Registered: 2012-07-10
Posts: 4
Loc: UK
And I'm guessing error code 0 is, as with everything else, a success, while anything else would be shown as a failure?

I spose the only way is to test it \:\) Thanks for the help.

Top
#205465 - 2012-07-16 11:09 AM Re: Forcing Error Codes [Re: SMAndy]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Correct.

See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#205466 - 2012-07-16 11:25 AM Re: Forcing Error Codes [Re: Mart]
SMAndy Offline
Just in Town

Registered: 2012-07-10
Posts: 4
Loc: UK
Excellent!

In that case, do you know how to customise the response buttons? I mean, Yes, No and Cancel might do...

That way I can force it to repeat itself if someone clicks "No" to a question of "do you want to install this now?" but it would work better if the button said "delay" or something...

I found this page: http://www.scriptlogic.com/Kixtart/htmlhelp/Functions/messagebox.htm to give me some ideas on the message box, but there doesn't seem to be a customisable section for what the buttons say.

Because Quit is a full exit in kix, can you do quit 2 to force an error code? Exit technically only ends a function, right?

Sorry for all the questions \:\) I'm VERY new to Kix.

Top
#205467 - 2012-07-16 11:51 AM Re: Forcing Error Codes [Re: SMAndy]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
You can also give exit codes to Quit. See page 41 of the 4.62 manual.

Customizing the text on a button is not possible with just kixtart. There is an add-on called kixforms that can do this. It comes in two flavors (.NET and classic) but if you are new to kixtart you will need to develop your skills a bit first before starting with kixforms imho.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#205468 - 2012-07-16 11:57 AM Re: Forcing Error Codes [Re: Mart]
SMAndy Offline
Just in Town

Registered: 2012-07-10
Posts: 4
Loc: UK
Thanks for all your help, if there were karma buttons here, I'd be upping yours.

edit: found the ratings \:\)


Edited by SMAndy (2012-07-16 11:58 AM)

Top
#205469 - 2012-07-16 08:37 PM Re: Forcing Error Codes [Re: SMAndy]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Kixforms is a pretty amazing add-on if you're going to be using kix a lot. It provides the ability to create full GUIs for kix scripts. The only downfall of it in my opinion, is that since it's a .dll file, it has to be registered on every client computer that will be using it. If that's not an issue in your environment, I would suggest looking into it.
Top
#205470 - 2012-07-16 08:45 PM Re: Forcing Error Codes [Re: ShaneEP]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: ShaneEP
Kixforms is a pretty amazing add-on if you're going to be using kix a lot. It provides the ability to create full GUIs for kix scripts.
...


Yep, for sure.

 Originally Posted By: ShaneEP

...
The only downfall of it in my opinion, is that since it's a .dll file, it has to be registered on every client computer that will be using it. If that's not an issue in your environment, I would suggest looking into it.


There is also an MSI version that you can easily deploy with a GPO.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#205471 - 2012-07-16 09:32 PM Re: Forcing Error Codes [Re: Mart]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Good to know Mart...It's been so long since I was in a legit network environment that I forget about GPOs lol.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 793 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.063 seconds in which 0.029 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org