Page 1 of 1 1
Topic Options
#64379 - 2002-04-09 11:59 PM Error codes
Chris Bingel Offline
Fresh Scripter

Registered: 2002-04-09
Posts: 22
Loc: Baltimore, MD
OK, I'm confuzzled.

Here is the offending snippet:
code:
:TIME
SETTIME "CONSTELLATION"

IF @error <> 0
GOTO WRITEERROR
ENDIF

...

:WRITEERROR

IF OPEN(1,"C:\kixtart.log",5) = 0
WRITELINE(1,@USERID + CHR(9) + @DATE + CHR(9) + @TIME + CHR(9) + @LSERVER + CHR(9) + $err + CHR(9) + @serror + CHR(13) + CHR(10))
ELSE
BEEP
MESSAGEBOX("Errors running logon script and unable to open log file.","WARNING!",0+48+0+0,10)
ENDIF

The problem is that the writeerror piece is outputting a return code of 0. What between the SETTIME and WRITELINE is generating a new @ERROR, and how do I get around it?

[ 10 April 2002, 00:04: Message edited by: Chris Bingel ]

Top
#64380 - 2002-04-10 12:16 AM Re: Error codes
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
yep - been there too my friend. The trick is to save-away the return status into a kixtart variable, lile $ERROR and $SERROR, eg:

:TIME
SETTIME "CONSTELLATION"
IF @error <> 0
 $ERROR = @ERROR
 $SERROR = @SERROR
 GOTO WRITEERROR
ENDIF

...

:WRITEERROR

IF OPEN(1,"C:\kixtart.log",5) = 0
 WRITELINE(1,@USERID + CHR(9) + @DATE + CHR(9) + @TIME + CHR(9) + @LSERVER + CHR(9) + $err + CHR(9) + $serror + CHR(13) + CHR(10))
ELSE
 BEEP
 MESSAGEBOX("Errors running logon script and unable to open log file.","WARNING!",0+48+0+0,10)
ENDIF



-Shawn

[ 10 April 2002, 00:17: Message edited by: Shawn ]

Top
#64381 - 2002-04-10 07:13 AM Re: Error codes
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We think that you should change $err to $error in your
writeline statement.
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#64382 - 2002-04-10 01:05 PM Re: Error codes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Here's my Interpretation off your offending snippet:

code:
 :TIME
SETTIME "CONSTELLATION"

IF @error <> 0
$err = @error ;<--- you missed this
$serr = @serror ;<--- I added this
GOTO WRITEERROR
ENDIF

...

:WRITEERROR

IF OPEN(1,"C:\kixtart.log",5) = 0
WRITELINE(1,@USERID + CHR(9) + @DATE + CHR(9) + @TIME + CHR(9) + @LSERVER + CHR(9) + $err + CHR(9) + $serr + CHR(13) + CHR(10)) ;<--- replaced @serror with $serr
ELSE
BEEP
MESSAGEBOX("Errors running logon script and unable to open log file.","WARNING!",0+48+0+0,10)
ENDIF

_________________________



Top
#64383 - 2002-04-10 01:14 PM Re: Error codes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Guess I know what kixtartlog will contain after you changed your code like we suggested :

"5 Access denied"

'Normal' users aren't allowed to change system time by default seems to be
the most likely reason for failing settime commands [Big Grin]

right ?

Jochen

[ 10 April 2002, 13:16: Message edited by: jpols ]
_________________________



Top
#64384 - 2002-04-10 01:23 PM Re: Error codes
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Just to make sure we're answering the right question...

Both WriteLine() and MessageBox() are functions that return a value.

If you don't care about the return value then supress the code using a variable assignment otherwise it will appear on the console, i.e.
code:
$Nul=WriteLine(...

and
code:
$Nul=MessageBox(...


Top
#64385 - 2002-04-10 01:35 PM Re: Error codes
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the question had two answers.
there was outputting case and then the real question how to get around missing the right error code...
_________________________
!

download KiXnet

Top
#64386 - 2002-04-10 03:10 PM Re: Error codes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
... ok,

to clarify the wrong error level finally :

open() resets it in your case

J.
_________________________



Top
#64387 - 2002-04-10 04:40 PM Re: Error codes
Chris Bingel Offline
Fresh Scripter

Registered: 2002-04-09
Posts: 22
Loc: Baltimore, MD
Curiouser and curiouser...

made the suggested change, and now the code breaks at a new point:
code:
:LOGONBANNER
WRITEVALUE ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","LegalNoticeCaption","Legal Notice","REG_DWORD")

IF @error <> 0
$error = @error
$serror = @serror
GOTO WRITEERROR
ENDIF

...


:WRITEERROR

IF OPEN(1,"C:\kixtart.log",5) = 0
WRITELINE(1,@USERID + CHR(9) + @DATE + CHR(9) + @TIME + CHR(9) + @LSERVER + CHR(9) + $err + CHR(9) + @serror + CHR(13) + CHR(10))
ELSE
BEEP
MESSAGEBOX("Errors running logon script and unable to open log file.","WARNING!",0+48+0+0,10)
ENDIF

And this outputs to c:\kixtart.txt:

code:
tester	2002/04/10	10:36:07	\\CON-BALT-PDC01		The operation completed successfully.


Top
#64388 - 2002-04-10 04:42 PM Re: Error codes
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Think you might want to fix-up that line:

WRITELINE(1,@USERID + CHR(9) + @DATE + CHR(9) + @TIME + CHR(9) + @LSERVER + CHR(9) + $err + CHR(9) + @serror + CHR(13) + CHR(10))

to:

WRITELINE(1,@USERID + CHR(9) + @DATE + CHR(9) + @TIME + CHR(9) + @LSERVER + CHR(9) + $error + CHR(9) + $serror + CHR(13) + CHR(10))

-Shawn

Top
#64389 - 2002-04-10 04:44 PM Re: Error codes
Chris Bingel Offline
Fresh Scripter

Registered: 2002-04-09
Posts: 22
Loc: Baltimore, MD
Ta.

But before I do that...MORE COFFEE!!!

Top
#64390 - 2002-04-10 04:45 PM Re: Error codes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Chris ,

I don't think so !

The script is probably is just running through to
:WRITEERROR because you don't exit it before ?

I guess this because there is no $err in your output [Wink]
_________________________



Top
#64391 - 2002-04-10 04:47 PM Re: Error codes
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
... or was it $error ?

Think you have to decide which to use [Big Grin]

J.
_________________________



Top
Page 1 of 1 1


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

Who's Online
0 registered and 1110 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.117 seconds in which 0.074 seconds were spent on a total of 12 queries. Zlib compression enabled.

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