(view source code of printers.kix as plain text)
; Printers.kix, Version 1.12; Written by Rob van der Woude; http://www.robvanderwoude.com; DefPrt subroutine written by Adriaan Westra; http://www.westra.speedlinq.nl/; Kix script to map LPT ports to network printers; using a personal configuration file (INI format); Tested in Windows NT 4 SP5 only;; Sample printers.ini:; [Mappings]; LPT2=\\server\printershare; LPT3=/DEL;; LPT1 not specified: map to default printer; Value /DEL: any existing mapping will be deleted;; Hide script executionSETCONSOLE( "HIDE" )
; Specify path for printers.ini here:$INI = "H:\PRINTERS.INI"
; Check if INI file existsIF EXIST( $INI )
; Read printer mapping for all ports specified$LPT1 = READPROFILESTRING( $INI, "Mappings", "LPT1" )
$LPT2 = READPROFILESTRING( $INI, "Mappings", "LPT2" )
$LPT3 = READPROFILESTRING( $INI, "Mappings", "LPT3" )
$LPT4 = READPROFILESTRING( $INI, "Mappings", "LPT4" )
$LPT5 = READPROFILESTRING( $INI, "Mappings", "LPT5" )
$LPT6 = READPROFILESTRING( $INI, "Mappings", "LPT6" )
$LPT7 = READPROFILESTRING( $INI, "Mappings", "LPT7" )
$LPT8 = READPROFILESTRING( $INI, "Mappings", "LPT8" )
ENDIF
; Delete existing mappingUSE LPT1: /DEL /PERSISTENT
; If LPT1 is specifiedIF $LPT1
; Display value read from INI file? "LPT1 = " + $LPT1
; Map to network printer unless /DEL was specifiedIF $LPT1 <> "/DEL"
USE LPT1: $LPT1
ENDIF
ELSE
; Map to default printer if LPT1 was not specifiedGOSUB "DefPrt"
ENDIF
; Except for the default printer mapping,; do the same for LPT2 through LPT8IF $LPT2
? "LPT2 = " + $LPT2
USE LPT2: /DEL /PERSISTENT
IF $LPT2 <> "/DEL"
USE LPT2: $LPT2
ENDIF
ENDIF
IF $LPT3
? "LPT3 = " + $LPT3
USE LPT3: /DEL /PERSISTENT
IF $LPT3 <> "/DEL"
USE LPT3: $LPT3
ENDIF
ENDIF
IF $LPT4
? "LPT4 = " + $LPT4
USE LPT4: /DEL /PERSISTENT
IF $LPT4 <> "/DEL"
USE LPT4: $LPT4
ENDIF
ENDIF
IF $LPT5
? "LPT5 = " + $LPT5
USE LPT5: /DEL /PERSISTENT
IF $LPT5 <> "/DEL"
USE LPT5: $LPT5
ENDIF
ENDIF
IF $LPT6
? "LPT6 = " + $LPT6
USE LPT6: /DEL /PERSISTENT
IF $LPT6 <> "/DEL"
USE LPT6: $LPT6
ENDIF
ENDIF
IF $LPT7
? "LPT7 = " + $LPT7
USE LPT7: /DEL /PERSISTENT
IF $LPT7 <> "/DEL"
USE LPT7: $LPT7
ENDIF
ENDIF
IF $LPT8
? "LPT8 = " + $LPT8
USE LPT8: /DEL /PERSISTENT
IF $LPT8 <> "/DEL"
USE LPT8: $LPT8
ENDIF
ENDIF
QUIT
; DefPrt subroutine, written by Adriaan Westra, http://people.a2000.nl/awestra:DefPrt ; Read default printer string from registry$SUBKEY = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
$VALUE = READVALUE( $SUBKEY, "Device" )
; Parse UNC only from string$OFFSET = INSTR( $VALUE, "," )
$LEN = $OFFSET - 1
$LPT1 = SUBSTR( $VALUE, 1, $LEN )
; Display UNC value found? "LPT1 = " + $LPT1 + " (Default Printer)"
; Actual mappingUSE LPT1: $LPT1
RETURN
page last modified: 2025-10-11; loaded in 0.0056 seconds