I believe that I have addressed Jens point about re-adding the printer on each login.
This has been updated in the FAQ section too..
Default Printer Configuration
Here is what the cleaned up code distills down to.
code:
BREAK ON
CLS
$subkey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"
$windir = READVALUE("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion","SystemRoot")
$systemdrive = SUBSTR($windir,1,2)
IF EXIST($windir+"\Printsetup.ini")
DEL $windir+"\Printsetup.ini"
ENDIF
IF (GETFILEATTR("H:") & 16)
$ps = "H:\Scripts_DO_NOT_DELETE\Printsetup.ini"
IF ((GETFILEATTR("H:\Scripts_DO_NOT_DELETE") & 16) = 0)
MD "H:\Scripts_DO_NOT_DELETE"
ENDIF
ELSE
$ps = $systemdrive+"\Scripts\Printsetup.ini"
IF ((GETFILEATTR($systemdrive+"\Scripts") & 16) = 0)
MD $systemdrive+"\Scripts"
ENDIF
ENDIF
$value = ReadValue($subkey,"Device")
IF Exist($ps)
$lpt1 = READPROFILESTRING($ps,"Printers","Default")
$rc = AddPrinterConnection($lpt1)
$rc = SetDefaultPrinter($lpt1)
ELSE
$lpt1 = SUBSTR($value,1,InStr($value,",")-1)
$rc = AddPrinterConnection($lpt1)
$rc = SetDefaultPrinter($lpt1)
ENDIF
SLEEP 1
IF INSTR($value,"\\")
$rc = WRITEPROFILESTRING($ps,"Printers","Default",$lpt1)
USE LPT1: $lpt1 /del /persistent
USE LPT1: $lpt1 /persistent
ENDIF
RETURN
Comments and suggestions are welcome.
Thanks,
Kent