#148747 - 2005-09-28 11:39 PM
SetDefaultPrinter() Overrides User Set Default Printer
|
BMM
Lurker
Registered: 2005-09-20
Posts: 2
|
Hi, I created script that automatically connects our users to our network printer and sets a default printer in the process. Problem is when users set their own default printers, the process changes the default back to whatever is in the script when they relogin.
Is there anyway to make kixtart not set a default printer if the user has manually set another default printer (such as a local printer)?
Thanks.
Brian
|
Top
|
|
|
|
#148749 - 2005-09-28 11:59 PM
Re: SetDefaultPrinter() Overrides User Set Default Printer
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
AddPrinterConnection( )
should not be setting a default printer. That would be done with
SetDefaultPrinter( )
If you want to remove a printer that is done with
DelPrinterConnection( )
There are also a few Printer related UDFs if needed as well. Look on one of the UDF sites for a sorted list.
http://www.kixhelp.com/udfs
|
Top
|
|
|
|
#148750 - 2005-09-29 12:07 AM
Re: SetDefaultPrinter() Overrides User Set Default Printer
|
BMM
Lurker
Registered: 2005-09-20
Posts: 2
|
Thanks, I am aware of those three functions. I am trying to find out if there is an easy way that someone had already worked out to determine if a user had local printers set as default before the script changed it to the network printer.
|
Top
|
|
|
|
#148753 - 2005-09-29 07:53 AM
Re: SetDefaultPrinter() Overrides User Set Default Printer
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
And this UDF will allow you to log all the printers installed on the system if wanted.
EnumPrinterConnections2() - Enumerates all connected printers http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=137527
|
Top
|
|
|
|
#148759 - 2005-09-29 04:44 PM
Re: SetDefaultPrinter() Overrides User Set Default Printer
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
BMM - I found this code on the boards. I don't actually use it to set my printers, I rem out the last lines so that I only record the current printers, but this looks like it might work for your needs. If there is a local printer set as default, it doesn't change to the network printer. You can populate the PrintSetup.ini with the printers you wish to add if there are none currently set.
Code:
;********** Default Printer Configuration ;This is to capture the Default Printer and get all network defined printers as well
$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
;********** Set Printsetup.ini file location $ps=('\\server\prtlog$') $ps=($ps+'\@wksta') 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($nprt,'\\') ;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
|
Top
|
|
|
|
#148763 - 2005-09-29 06:30 PM
Re: SetDefaultPrinter() Overrides User Set Default Printer
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
Well, I must've believed they worked when I copied them into my script.
It doesn't really matter if they work, I guess. I posted the script I found and partially use and was just indicating that it wasn't my script, but rather gathered from the boards. It is a nice nod to someone else if you can give them credit for their code and for helping those of us who are kix-challenged. Too bad I don't have working links....
|
Top
|
|
|
|
#148765 - 2005-09-29 07:53 PM
Re: SetDefaultPrinter() Overrides User Set Default Printer
|
tjcarst
Hey THIS is FUN
Registered: 2003-09-08
Posts: 243
Loc: USA
|
I haven't seen that one before. Maybe that will work for BMM.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 507 anonymous users online.
|
|
|