Page 1 of 1 1
Topic Options
#143113 - 2005-07-06 06:25 PM Default Printer Error in Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Error:
Quote:


ERROR: error in USE statement!
SCRIPT: \\dc\NETLOGON\newscript\function.kx
Line:409




Note: the Error is on this line ;<<< **

I did go and look on this person's H: drive and the INI file exists, but still generates the error.
Code:

; -- DEFAULT PRINTER - ALL
FUNCTION DEFPRTR()
; Re-Write at http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=004308
; By Kdyer & Lonkero (15th april 2003)

; Re-Write of http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=10;t=000021
;Default Printer Configuration
;This is to capture the Default Printer and get all network defined printers as well
; Ref. http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=1&t=006790
; Ref. http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000221
DIM $prireg,$x,$i,$rc,$ps,$loc,$dev,$nprt,$key
SELECT
CASE
@wksta='MAILSTATION1' OR @wksta='MAILSTATION2' ; -- MAIL STATION PCS
RETURN
CASE
INSTR(@wksta,'TRAIN') ; -- TRAINING SYSTEMS
USE LPT1: /delete
$rc=ADDPRINTERCONNECTION('\\PRINTSERVER\PRINTER-P18')
SLEEP '0.5'
$rc=SETDEFAULTPRINTER('\\PRINTSERVER\PRINTER-P18')
SLEEP '0.5'
USE LPT1: '\\PRINTSERVER\PRINTER-P18'
RETURN
ENDSELECT
$loc='HKCU\Network\LPT1'
$dev='HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices'
$nprt=split(READVALUE('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows','Device'),',')[0]
IF EXIST('H:')
$ps='H:\Scripts_DO_NOT_DELETE'
ELSE
$ps=LEFT('%WINDIR%',2)+'\Scripts'
ENDIF
IF 0=EXIST($ps)
MD $ps
ENDIF
SELECT
CASE
Ltrim(Split(@ipaddress0,'.')[0])+'.'+Ltrim(Split(@ipaddress0,'.')[1])='1.1'
$ps=$ps+'\OFFICE1.ini'
CASE
Ltrim(Split(@ipaddress0,'.')[0])+'.'+Ltrim(Split(@ipaddress0,'.')[1])='2.2'
$ps=$ps+'\OFFICE2.ini'
CASE
1
$ps=$ps+'\PRINTSETUP.ini'
ENDSELECT

$i=0
DO
IF '\\'=LEFT($x,2)
$prireg=$prireg+$x
ENDIF
$x=ENUMVALUE($dev,$i)
$i=$i+1
UNTIL @error
IF LEN($prireg)
$rc=WRITEPROFILESTRING($ps,'Printers','','')
$prireg=split($prireg,'\\')
FOR $i=1 TO ubound($prireg)
$rc=WRITEPROFILESTRING($ps,'Printers',$i,'\\'+$prireg[$i])
NEXT
ENDIF
SELECT
CASE
INSTR($nprt,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG
$rc=WRITEPROFILESTRING($ps,'Printers','Default',$nprt)
USE LPT1: /delete /persistent
USE LPT1: $nprt
CASE
$nprt='' AND EXIST($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO
FOR EACH $key IN split(readprofilestring($ps,'Printers',''),chr(10))
$rc=addprinterconnection(readprofilestring($ps,'Printers',$key))
NEXT
$nprt=READPROFILESTRING($ps,'Printers','Default')
$rc=SETDEFAULTPRINTER($nprt)
USE LPT1: $nprt ;<<< ** ERROR ON THIS LINE
; CASE
; (INSTR($nprt,'Generator') OR INSTR($nprt,'Image Writer')) AND EXIST($ps) ;MS-OFFICE PRINTER(S), LOAD PRINTERS FROM SAVED INFO
; FOR EACH $key IN SPLIT(READPROFILESTRING($ps,'Printers',''),chr(10))
; $rc=ADDPRINTERCONNECTION(READPROFILESTRING($ps,'Printers',$key))
; NEXT
; $rc=SETDEFAULTPRINTER(READPROFILESTRING($ps,'Printers','Default'))
; USE LPT1: READPROFILESTRING($ps,'Printers','Default')
CASE
NOT INSTR($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING
USE LPT1: /delete /persistent
ENDSELECT
ENDFUNCTION



Thanks,

Kent


Edited by kdyer (2005-07-06 06:26 PM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#143114 - 2005-07-06 06:38 PM Re: Default Printer Error in Script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Well if the script works for other users then one has to assume that their is some other issue like either SHARE or FILE ACL or similar otherwise the script would error for ALL users. Maybe quit using the /t tokenized files for now until you get this whole thing working well, then try the tokenized files again. Remember that var scope can easily bite you with using the Include files.
 

 


Edited by NTDOC (2005-07-06 06:39 PM)

Top
#143115 - 2005-07-06 06:52 PM Re: Default Printer Error in Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Doc,

I don't think changing all of our users back is going to be an option.

I figured it out as I went back to see what the user had.

The original code has:
Code:

$nprt=READPROFILESTRING($ps,'Printers','Default')
$rc=SETDEFAULTPRINTER($nprt)
USE LPT1: $nprt ;<<< ** ERROR ON THIS LINE



Here is what I changed it to:
Code:

$nprt=READPROFILESTRING($ps,'Printers','Default')
IF @ERROR=0
$rc=SETDEFAULTPRINTER($nprt)
USE LPT1: $nprt
ENDIF



Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#143116 - 2005-07-06 07:02 PM Re: Default Printer Error in Script
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
No problem, only suggested you get off the tokenized files till you fix the issue as it would be easier to track down.

Just doesn't make sense that it would not work for one user but does for others is all.
 

Top
#143117 - 2005-07-06 07:13 PM Re: Default Printer Error in Script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kent, how that it is possible that a user has no default printer in the ini?
someone manually touched the ini?
_________________________
!

download KiXnet

Top
#143118 - 2005-07-08 06:11 AM Re: Default Printer Error in Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Lonk,

See my "Cardinal rule" breaking post. I did a system rollback and my version of KiX was off when tokenizing.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#143119 - 2005-07-08 11:20 AM Re: Default Printer Error in Script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
cardinal rule...
this is not about kix version but wrong style ini like you admitted above.
_________________________
!

download KiXnet

Top
#143120 - 2005-07-08 03:19 PM Re: Default Printer Error in Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Huh? Are you saying that we need to go back and look at the code again and update it?

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#143121 - 2005-07-08 03:59 PM Re: Default Printer Error in Script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
this code worked before, right?
so, it's not about tokenization if it failed now, but about something else.
like a bugfix.
_________________________
!

download KiXnet

Top
#143122 - 2005-07-09 12:51 AM Re: Default Printer Error in Script
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
No.. It is fine now.
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

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

Generated in 0.095 seconds in which 0.073 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