Page 1 of 1 1
Topic Options
#70950 - 2002-10-22 12:25 AM HELP: Canīt get BREAK ON to function
redniels Offline
Fresh Scripter

Registered: 2002-10-21
Posts: 19
Loc: Netherlands
Hello,

Iīm using kixstart for a while now, and while I canīt call myself "good" at it, Iīm not a complete newbie..

I have 2 scripts which have to use BREAK ON, thus make the user[s] able to close the script before it exits.. ever since weīve gone from kix 3.62 to later versions [4.02 etc] I canīt get BREAK ON to work..Users just canīt exit from the script and itīs a pain. Pls tell me what I do wrong because I canīt see it..

Included here is a copy of a script I wrote to make it easier for my [l]users to connect to a printer. For many of them browsing the network/server for a printer is a daunting task which was just to complicated.. [Mad] This script allows them to just enter the printername & hit enter..

anyway: with kix version =< 3.62 the users could exit from it, but now...no more. worse still, even after the script has completed the window is not closeable, except afcourse when they logoff/logon..

the script output is in dutch, but that shouldnīt be a big problem...

the script uses a HIDDEN$ [doh] share on the printserver on which everyone has READ rights to check if a server is online..

the script calls a batch file d.bat which is very simple it is just the following 2 lines:

@ECHO OFF
START %PRINTERVAR%

the printerad.kix file:
[iīve replaced company, groups, department & servernames with fictional ones, hope you understand why..]
also I had to replace normal parenthesis with [ and ]to be able to post it here...strange..or not?

;addprinter script, dit script maakt op aanwijzingen van een gebruiker een printer aan
;dit is onder Windows95 en Windows NT4 getest,
;werkt voor 99,9% zeker ook onder Windows2000, Windows XP, Windows 98 en Windows ME
; variabelen in gebruik:
;$SERVERNAAM
;$PRINTERNAAM
;$ANSWER1
;LABELS in gebruik
;SERVERSELECT
;PRINTERSELECT
;PRINTERDIALOOG1
;GO1
; v2.0 2 JAN 2001 [C]NPK [BREAK=ON ERBIJ]

BREAK ON
color y+/b
cls
flushkb
:SERVERSELECT
? "=================================================================="
? "COMPANYNAME, DEPARTMENT 2001"
? "een moment alstublieft..."
? "=================================================================="

if INGROUP ["BO"] GOSUB "SRV1" endif
if INGROUP ["GO"] GOSUB "SRV1" endif
if INGROUP ["RD"] GOSUB "SRV1" endif
if INGROUP ["PU"] GOSUB "SRV1" endif
if INGROUP ["CS"] GOSUB "SRV1" endif
if INGROUP ["BW"] GOSUB "SRV1" endif
if INGROUP ["BD"] GOSUB "SRV2" endif
if INGROUP ["BR"] GOSUB "SRV2" endif
if INGROUP ["CU"] GOSUB "SRV2" endif
if INGROUP ["EX"] GOSUB "SRV2" endif

if $servernaam <> "SERVER2"
if $servernaam <> "SERVER1"
CLS
? "=================================================================="
? "Dit script kan GEEN Printserver vinden! Misschien is er iets mis "
? "met een van de servers of met het netwerk. Neem svp contact op met"
? "de COMPANY Klantenbalie, telefoonnummer xxxxx"
? "=================================================================="
sleep 10
goto UIT
endif
endif

color w+/b
? " De beschikbare server in deze sessie is $SERVERNAAM geworden...."
color y+/b

? "=================================================================="
cls
GOSUB PRINTERSELECT
GOSUB GO1
? "dit programma is klaar, Windows printerinstallatie is gestart..."
? "=================================================================="

:UIT
EXIT

:SRV1
if exist ["\\SERVER1\HIDDEN$\CHECK.TXT"] $SERVERNAAM = "SERVER1"
ELSE $SERVERNAAM = "SERVER2"
ENDIF
RETURN

:SRV2
if exist ["\\SERVER2\HIDDEN$\CHECK.TXT"] $SERVERNAAM = "SERVER2"
ELSE $SERVERNAAM = "SERVER1"
ENDIF
RETURN

:PRINTERSELECT
? "=================================================================="
? "toets de Printernaam in, dit staat op iedere printer op een"
? "sticker, en begint altijd met PR0nummer [voorbeeld: PR0511]"
? "als U de juiste printer heeft ingevuld, druk dan op ENTER"
color W+/b
? "LET OP: EERSTE cijfer is een NUL geen letter O!"
color y+/b
? "=================================================================="

color w+/b
? "-->"
color r+/b
GETS $PRINTERNAAM
color y+/b
GOSUB PRINTERDIALOOG1
RETURN

:PRINTERDIALOOG1
cls
? "=================================================================="
? "De gekozen PRINTER naam is"
color r+/b
? "$PRINTERNAAM"
color y+/b
? "is dit juist?"
? "ENTER doorgaan, toets N[ee]om opnieuw een printerselectie te maken"
? "=================================================================="
color w+/b
? "-->"
color y+/b
GET $ANSWER1
IF $ANSWER1 = "n" OR $ANSWER1 = "N" GOSUB PRINTERSELECT
ENDIF
RETURN

:GO1
SETL "PRINTERVAR=\\$SERVERNAAM\$PRINTERNAAM"
RUN "D.BAT"
RETURN

Top
#70951 - 2002-10-22 12:52 AM Re: HELP: Canīt get BREAK ON to function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
quess this is more fitting forum for your post...

first (before getting to the problems) I quess some syntax cleaning could be usable.

anyway, I haven't got break on working either.
and nowadays, break off works neither!

what comes to the script not ending, you could tell us, on what os. I quess it's on win9x, right?

also, using goto is not good habit.
neither specifying exit without error code as it then reads the next stuff for errorcode.
about your brackets, if it works like:
if ingroup ["some"]

ok, but correct way would be:
if ingroup("some")

anyway, I'm not trying now to fix your code here but to make it easier for others to read it too.
so:
code:
BREAK ON
color y+/b
cls
flushkb

;SERVERSELECT
? "=================================================================="
? "COMPANYNAME, DEPARTMENT 2001"
? "een moment alstublieft..."
? "=================================================================="

select
case INGROUP("BO") GOSUB "SRV1"
case INGROUP("GO") GOSUB "SRV1"
case INGROUP("RD") GOSUB "SRV1"
case INGROUP("PU") GOSUB "SRV1"
case INGROUP("CS") GOSUB "SRV1"
case INGROUP("BW") GOSUB "SRV1"
case INGROUP("BD") GOSUB "SRV2"
case INGROUP("BR") GOSUB "SRV2"
case INGROUP("CU") GOSUB "SRV2"
case INGROUP("EX") GOSUB "SRV2"
case 1
CLS
? "=================================================================="
? "Dit script kan GEEN Printserver vinden! Misschien is er iets mis "
? "met een van de servers of met het netwerk. Neem svp contact op met"
? "de COMPANY Klantenbalie, telefoonnummer xxxxx"
? "=================================================================="
sleep 10
exit 1
endselect

color w+/b
? " De beschikbare server in deze sessie is $SERVERNAAM geworden...."
color y+/b

? "=================================================================="
cls
GOSUB PRINTERSELECT
GOSUB GO1
? "dit programma is klaar, Windows printerinstallatie is gestart..."
? "=================================================================="
exit 0

:SRV1
if exist("\\SERVER1\HIDDEN$\CHECK.TXT")
$SERVERNAAM = "SERVER1"
ELSE
$SERVERNAAM = "SERVER2"
ENDIF
RETURN

:SRV2
if exist ["\\SERVER2\HIDDEN$\CHECK.TXT"]
$SERVERNAAM = "SERVER2"
ELSE
$SERVERNAAM = "SERVER1"
ENDIF
RETURN

:PRINTERSELECT
? "=================================================================="
? "toets de Printernaam in, dit staat op iedere printer op een"
? "sticker, en begint altijd met PR0nummer [voorbeeld: PR0511]"
? "als U de juiste printer heeft ingevuld, druk dan op ENTER"
color W+/b
? "LET OP: EERSTE cijfer is een NUL geen letter O!"
color y+/b
? "=================================================================="

color w+/b
? "-->"
color r+/b
GETS $PRINTERNAAM
color y+/b
GOSUB PRINTERDIALOOG1
RETURN

:PRINTERDIALOOG1
cls
? "=================================================================="
? "De gekozen PRINTER naam is"
color r+/b
? "$PRINTERNAAM"
color y+/b
? "is dit juist?"
? "ENTER doorgaan, toets N[ee]om opnieuw een printerselectie te maken"
? "=================================================================="
color w+/b
? "-->"
color y+/b
GET $ANSWER1
IF $ANSWER1 = "n"
GOSUB PRINTERSELECT
ENDIF
RETURN

:GO1
SETL "PRINTERVAR=\\$SERVERNAAM\$PRINTERNAAM"
RUN "D.BAT"
RETURN

but it still has a lot of sub scripts...
quess you have worked with bats a lot [Wink]

cheers.
_________________________
!

download KiXnet

Top
#70952 - 2002-10-21 04:30 PM Re: HELP: Canīt get BREAK ON to function
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
If you are mainly dealing with Win9x machines you might look at these posts.

http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=003861

http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=003867

From these threads you should note Lonkero seems to becoming our resident expert on this subject.
_________________________
Jack

Top
#70953 - 2002-10-21 11:48 PM Re: HELP: Canīt get BREAK ON to function
redniels Offline
Fresh Scripter

Registered: 2002-10-21
Posts: 19
Loc: Netherlands
first off, thanks guys for the quick response, and yes, this is a more suitable place for this question..

now, to answer your questions:
1-which Windows:
We're using W9x, NT4, W2K, WXP.. all of them have this problem (break on not functioning) and indeed after completing the script only w9x can't close the box..

2-Goto Sucks.
You're right. In the first kix "lesson" I got from an old (if you're reading this: Hi, bart!)collegue of mine, he told me: "Goto sucks. period. it's spaghetti. And I don't like spaghetti.etc etc(continue rant about goto) :-)
I know I should use gosub, but old habits die hard, and yes, indeed, I'm still a batch guy.

3-fix my code
Please do! :-) I know I'm not a clean or gifted script writer, that's the reason I became a sysadmin, (users don't look at it and still think I'm great) :-) (joke!) no, serious, I've never took the time to clean it up, (too busy) it just worked & I never again looked at it..till a few months ago when we started using 4.02.

btw: If you think this one is messy, i've got another one for you if you're interested..Even I can see that that one is a real load of... ;-) but hey, it works! so again, I never took the time to change it..maybe I should..

4- I'm not that comfortable about distributing a hacked .dll to all our W9X workstations...
and even then, We still have a problem on NT4/W2K/WXP. right?
If I understand you guys correctly it's a "bug" in kix, since version 4.02? or do I completely miss the bus here..?

maybe I should just call kix32 V3.62 for this script as a quick & dirty solution...

and lonkero, thanks for the cleanup..

Top
#70954 - 2002-10-22 03:14 AM Re: HELP: Canīt get BREAK ON to function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
With regards to the BREAK ON issue. I have not noticed that it is not working. With BREAK OFF an attempt to close a script under at least Windows 2000 results in a logoff even if the script is running after a login completes. With BREAK ON I can close a script without being logged off. This, in my mind, does indicate that BREAK ON|OFF is indeed working as advertised.

[ 22. October 2002, 03:15: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#70955 - 2002-10-22 09:21 AM Re: HELP: Canīt get BREAK ON to function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
redniels, if your wksta is failing too, put everyone else to use the old kix and make yourself as cript which you use with 4.xx

this way you can debug the code without harming the normal users.

[ 22. October 2002, 09:22: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#70956 - 2002-10-22 04:25 PM Re: HELP: Canīt get BREAK ON to function
Jack Lothian Offline
MM club member
*****

Registered: 1999-10-22
Posts: 1169
Loc: Ottawa,Ontario, Canada
I believe these issues are handled by policies in Win2000 & WinXP. I believe that the article Waltz references in the above threads I referenced points out the solution for these system.

http://msdn.microsoft.com/msdnmag/issues/02/09/CQA/default.aspx

In my opinion, the suggested changes for stopping the use of cntl+alt+del in Win9x are just as much a hack as the changes made to MSNET32.dll. I am not sure solid security in Win9x can be provided without some type of "hacks". Hack is a scary power word use another word.

If the DOS box is not closing only in Win9x scripts my guess is the script is not finishing normally & is hanging.

I tend to aggree with Jens, I think your script may have other problems that are obsuring the issue.

[ 22. October 2002, 16:26: Message edited by: Jack Lothian ]
_________________________
Jack

Top
#70957 - 2002-10-22 05:23 PM Re: HELP: Canīt get BREAK ON to function
redniels Offline
Fresh Scripter

Registered: 2002-10-21
Posts: 19
Loc: Netherlands
And indeed, you all were right..

the original script(s) needed some (understatement) rewriting and after that the spaghetti programming was gone and it worked like before..(break on that is) Itīs still too large, and Iīm sure that thereīs a better way to check if a server is online, but thatīs a "to do" for another time.

The problem was completely eliminated after I used the SHELL command instead of RUN in the script..strange...? [Confused]

the new code, which now functions, is found below..

code:
  
BREAK ON
color y+/b
cls
flushkb
? "=================================================================="
? "COMPANY, DEPARTMENT 2001"
? "een moment alstublieft..."
? "=================================================================="

SELECT
CASE INGROUP("BO") $servernaam="SERVER1"
CASE INGROUP("GO") $servernaam="SERVER1"
CASE INGROUP("RD") $servernaam="SERVER1"
CASE INGROUP("PU") $servernaam="SERVER1"
CASE INGROUP("CS") $servernaam="SERVER1"
CASE INGROUP("BW") $servernaam="SERVER1"
CASE INGROUP("BD") $servernaam="SERVER2"
CASE INGROUP("BR") $servernaam="SERVER2"
CASE INGROUP("CU") $servernaam="SERVER2"
CASE INGROUP("EX") $servernaam="SERVER2"
CASE 1
$STATUS=VOUT
ENDSELECT

:PRINTERSELECT

if exist ("\\$servernaam\HIDDEN$\CHECK.TXT")
? "=================================================================="
? "toets de Printernaam in, dit staat op iedere printer op een"
? "sticker, en begint altijd met PR0nummer (voorbeeld: PR0511)"
? "als u de juiste printer heeft ingevuld, druk dan op ENTER"
color W+/b
? "LET OP: EERSTE cijfer is een NUL geen letter O!"
color y+/b
? "=================================================================="
color w+/b
? "-->"
color r+/b
GETS $PRINTERNAAM
color y+/b
cls
? "=================================================================="
? "De gekozen PRINTER naam is"
color r+/b
? "$PRINTERNAAM via $servernaam"
color y+/b
? "is dit juist?"
? "ENTER doorgaan, toets N(ee)om opnieuw een printerselectie te maken"
? "=================================================================="
color w+/b
? "-->"
color y+/b
GET $ANSWER1
IF $ANSWER1 = "n" GOSUB PRINTERSELECT
ENDIF

SETL "PRINTERVAR=\\$SERVERNAAM\$PRINTERNAAM"
SHELL "%WINDIR%\DWP\D.BAT"
$STATUS=OK

RETURN

RETURN

ELSE
IF $SERVERNAAM="SERVER2"
IF EXIST ("\\SERVER1\HIDDEN$\CHECK.TXT")
$servernaam="SERVER1"
$STATUS=REDO
ELSE
$STATUS=VOUT
ENDIF
ENDIF

IF $SERVERNAAM="SERVER1" AND $STATUS <> "REDO"
IF EXIST ("\\SERVER2\HIDDEN$\CHECK.TXT")
$SERVERNAAM="SERVER2"
$STATUS=REDO
ELSE
$STATUS=VOUT
ENDIF
ENDIF

ENDIF

if $STATUS=VOUT
CLS
? "=================================================================="
? "Dit script kan GEEN Printserver vinden! Misschien is er iets mis "
? "met een van de servers of met het netwerk."
? "Het kan ook zijn dat voor u geen hoofdgroep is gezet.(PU, BD, etc)"
? "Neem contact op met de DEPARTMENT Klantenbalie, telefoonnummer xxx xx xx"
? "=================================================================="
sleep 10
endif

IF $STATUS = "REDO"
GOSUB PRINTERSELECT
ENDIF

? "status was "$status"
EXIT 0

All in all: problem solved, once again thanks all for putting me back on track..

Top
#70958 - 2002-10-22 05:30 PM Re: HELP: Canīt get BREAK ON to function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that is still the bug of it.

it won't work if you have endless loop eating up all processor power.
and that is only reason why I would need it.

it needs time to be raisen and if the other script is eating lot's of processor time, it's left to handled later.
_________________________
!

download KiXnet

Top
#70959 - 2002-10-22 05:32 PM Re: HELP: Canīt get BREAK ON to function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please read Not quite everything you wanted to know about RUN and SHELL .
Please put a
code:
cls
exit 0

at the end of your batch files. This seems to successfully close batch files under Windows 9x/NT/2000/XP.
_________________________
There are two types of vessels, submarines and targets.

Top
#70960 - 2002-10-22 05:46 PM Re: HELP: Canīt get BREAK ON to function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
quote:

worse still, even after the script has completed the window is not closeable, except afcourse when they logoff/logon..

meaning that it has nothing to do with this closing of window.
rather, hanging script.
_________________________
!

download KiXnet

Top
#70961 - 2002-10-25 11:10 AM Re: HELP: Canīt get BREAK ON to function
redniels Offline
Fresh Scripter

Registered: 2002-10-21
Posts: 19
Loc: Netherlands
quote:

that is still the bug of it.

it won't work if you have endless loop eating up all processor power.
and that is only reason why I would need it.

it needs time to be raisen and if the other script is eating lot's of processor time, it's left to handled later


Iīm beginning to feel like a real user. now I know what they go through everyday.

maybe I should just use %comspec% and remove the whole batch thingy...

Top
#70962 - 2002-10-25 11:31 AM Re: HELP: Canīt get BREAK ON to function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh...
in logon script the user shouldn't be allowed to break the script anyway.

and about your quote, I was quessing and after testing, I can't get break on to work anyway (wkix32), so it just isn't working, period.

but, if your script is working fine, you don't need to get it working.
_________________________
!

download KiXnet

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 1452 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.127 seconds in which 0.04 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