#74455 - 2003-04-14 02:19 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Shows you things like: Error Line 12 Missing Comma..
Kent
|
Top
|
|
|
|
#74456 - 2003-04-14 02:22 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Thing that is kind of nagging at me now is if the client has a USB Printer..
For example...
INSTR($nptr,'LPT') AND READVALUE($loc,'RemotePath')<>''
For example, I have installed a Brother MFC 8700 here on the USB port and it shows - winspool,Ne01:
And not - winspool,LPT1:
Thanks,
Kent [ 14. April 2003, 14:25: Message edited by: kdyer ]
|
Top
|
|
|
|
#74457 - 2003-04-14 02:30 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Think this should cover if the printer is on LPT, USB, etc.
code:
CASE NOT INSTR($nptr,'\\') AND READVALUE($loc,'RemotePath')<>'' ...
Kent [ 14. April 2003, 14:31: Message edited by: kdyer ]
|
Top
|
|
|
|
#74460 - 2003-04-14 02:37 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Wait a second..
Let's think about this scenario..
They were printing on a network printer and been redirecting LPT1 to the network printer..
They have IT order a new local printer, but they still want access to the network-based color printer.. Shouldn't you check to see if they are re-mapping LPT1 to the network?
Kent [ 14. April 2003, 14:38: Message edited by: kdyer ]
|
Top
|
|
|
|
#74463 - 2003-04-14 04:15 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Lonk,
You are right.. It doesn't matter. If we use the NOT INSTR($nptr,'\\') it covers this.
Kent
|
Top
|
|
|
|
#74464 - 2003-04-14 10:45 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Running into a problem though...
Connected into another workstation after setting my workstation to a have a local printer..
It errors on - USE LPT1: $lpt1 /persistent
The INI File has: code:
[Printers] 1=\\printserver\printserver-p19 2=\\printserver\printserver-p27
So, when I login to the other workstation, there is no entry for code:
[Printers] 1=\\printserver\printserver-p19 2=\\printserver\printserver-p27 Default=\\printserver\printserver-p27
For example..
Kent
|
Top
|
|
|
|
#74466 - 2003-04-15 08:56 AM
Re: Re-Write of "Default Printer" FAQ
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
k, newist one with old postprep engine (no tabs support )
;Re-Write of http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=2;t=004308 By lonkero & kdyer font> ;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
$loc='HKEY_CURRENT_USER\Network\LPT1' $reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion' $dev=$reg+'\Devices' $ptr=$reg+'\Windows' $nptr=READVALUE($ptr,'Device') $lpt=split($nptr,',')[0] $sysdrv=SUBSTR('%WINDIR%',1,2) dim $priReg, $x, $i, $rc, $ps
IF EXIST('H:') $ps='H:\Scripts_DO_NOT_DELETE' ELSE $ps=$sysdrv+'\Scripts' ENDIF IF 0=EXIST($ps) MD $ps ENDIF $ps=$ps+'\Printsetup.ini'
$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($nptr,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG $rc=WRITEPROFILESTRING($ps,'Printers','Default',$lpt) USE LPT1: /delete /persistent USE LPT1: $lpt /persistent CASE $nptr='' AND EXIST($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO FOR EACH $key IN split(readprofilestring($ps,'Printers',''),chr(10)) $nul=addprinterconnection(readprofilestring($ps,'Printers',$key)) NEXT $lpt=READPROFILESTRING($ps,'Printers','Default') $rc=SETDEFAULTPRINTER($lpt) USE LPT1: $lpt /persistent CASE ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE ANY NETWORK MAPPING NOT INSTR($nptr,'\\') USE LPT1: /delete /persistent ENDSELECT
_________________________
!download KiXnet
|
Top
|
|
|
|
#74467 - 2003-04-15 09:35 AM
Re: Re-Write of "Default Printer" FAQ
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
and with some cracking of engine we get it cleaner:
; 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 $loc='HKEY_CURRENT_USER\Network\LPT1' $reg='HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion' $dev=$reg+'\Devices' $nprt=split(READVALUE($reg+'\Windows','Device'),',')[0] $sysdrv=SUBSTR('%WINDIR%',1,2) dim $priReg, $x, $i, $rc, $ps IF EXIST('H:') $ps='H:\Scripts_DO_NOT_DELETE' ELSE $ps=$sysdrv+'\Scripts' ENDIF IF 0=EXIST($ps) MD $ps ENDIF $ps=$ps+'\Printsetup.ini' $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($nptr,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG $rc=WRITEPROFILESTRING($ps,'Printers','Default',$nprt) USE LPT1: /delete /persistent USE LPT1: $nprt /persistent CASE $nprt='' AND EXIST($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO FOR EACH $key IN split(readprofilestring($ps,'Printers',''),chr(10)) $nul=addprinterconnection(readprofilestring($ps,'Printers',$key)) NEXT $nprt=READPROFILESTRING($ps,'Printers','Default') $rc=SETDEFAULTPRINTER($nprt) USE LPT1: $nprt /persistent CASE NOT INSTR($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING USE LPT1: /delete /persistent ENDSELECT
[ 15. April 2003, 09:46: Message edited by: Lonkero ]
_________________________
!download KiXnet
|
Top
|
|
|
|
#74468 - 2003-04-16 09:08 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Correction..
Found:
code:
CASE INSTR($nptr,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG
Changed it to:
code:
CASE INSTR($nprt,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG
Updated the FAQ as well.
Thanks,
Kent
|
Top
|
|
|
|
#74470 - 2003-04-16 10:27 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Switched my local printer to be the default.. Removed all printers (local and net). Could not find the default anymore.. Could not write it either.
Kent
|
Top
|
|
|
|
#74472 - 2003-04-18 02:46 PM
Re: Re-Write of "Default Printer" FAQ
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
So...
Are there any other takers of this? Or, do you use Roaming Profiles and the server does all of this for you?
Kent
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 2145 anonymous users online.
|
|
|