Jens raises a good point. If you had a printer on the USB port, for example you would do "printer pooling" use it on LPT1 too.
However... if you want.. This maybe it..
OK.. Let's whittle this down a bit.
code:
$subkey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
$value = ReadValue( $subkey, "Device" )
IF 0 = InStr($value, "") ; -- IT IS NULL
RETURN ; -- NO PRINTER NOR INI FILE FOUND
ENDIF
; -- Let's manipulate some strings
$offset = InStr( $value, "," ) ; Parse name from string
$len = $offset - 1
$lpt1 = SUBSTR( $value, 1, $len )
IF (ExistKey("HKEY_CURRENT_USER\Network\LPT1") = 0)
; -- If the printer has been mapped then delete it to refresh the connection
; -- Delete the printer
USE LPT1: $lpt1 /del /persistent
; -- Refresh the connection to the printer as LPT1 with the string captured above
USE LPT1: $lpt1 /persistent
RETURN
ELSE
; -- ASSUME THE PRINTER HAS NOT BEEN DONE WITH A NET USE COMMAND
; -- Add it in as LPT1 anyway
USE LPT1: $lpt1 /persistent
RETURN
ENDIF
HTH,
Kent