Page 1 of 2 12>
Topic Options
#148747 - 2005-09-28 11:39 PM SetDefaultPrinter() Overrides User Set Default Printer
BMM Offline
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
#148748 - 2005-09-28 11:45 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, you need to know when the user has set the printer and when it's set by the script.

once you have that figured out, you can script it easily.
_________________________
!

download KiXnet

Top
#148749 - 2005-09-28 11:59 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
NTDOC Administrator Offline
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 Offline
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
#148751 - 2005-09-29 12:14 AM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
think what doc ment that if you just add printers, the current default printer will be default.

anyways, what you need is a script that queries the current default printer.
and such script can be found in the udf library.
_________________________
!

download KiXnet

Top
#148752 - 2005-09-29 01:39 AM Re: SetDefaultPrinter() Overrides User Set Default Printer
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
oh! You mean like this one?

GetDefaultPrinter() - Returns default printer
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=117544

Top
#148753 - 2005-09-29 07:53 AM Re: SetDefaultPrinter() Overrides User Set Default Printer
NTDOC Administrator Offline
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
#148754 - 2005-09-29 03:10 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Just one question... How can a script tell if a user selected a default vs. the system picked the default? I mean, you ALWAYS have a default whether you choose or the system chooses for you.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148755 - 2005-09-29 03:29 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that's why I said that all you need to know is when it's set by user.
rest is just downhill
_________________________
!

download KiXnet

Top
#148756 - 2005-09-29 03:50 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I know what you said Jooel, but you speak on such an esoteric level that one needs the delonkenizer 2.0 to decode.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148757 - 2005-09-29 04:00 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
right...
hmm. I thought the latest release was 1.7.4.23
_________________________
!

download KiXnet

Top
#148758 - 2005-09-29 04:20 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Right again... 2.0 is vapourware
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#148759 - 2005-09-29 04:44 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
tjcarst Offline
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
#148760 - 2005-09-29 04:50 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
looks familiar...
_________________________
!

download KiXnet

Top
#148761 - 2005-09-29 06:09 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
tjcarst Offline
Hey THIS is FUN

Registered: 2003-09-08
Posts: 243
Loc: USA
Yes, as I noted I found it on the boards here. The original links no longer work. Here they are:

;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

* Edited to add a couple more that don't work, but were saved with script:
; 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


Edited by tjcarst (2005-09-29 06:31 PM)

Top
#148762 - 2005-09-29 06:18 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
is either one supposed to work?
_________________________
!

download KiXnet

Top
#148763 - 2005-09-29 06:30 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
tjcarst Offline
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
#148764 - 2005-09-29 07:00 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmmm...
there is the one version by MCA in the FAQ:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB10&Number=81655
_________________________
!

download KiXnet

Top
#148765 - 2005-09-29 07:53 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
tjcarst Offline
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
#148766 - 2005-09-29 08:01 PM Re: SetDefaultPrinter() Overrides User Set Default Printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, not so much of an FAQ as an function introduction post.

the wanted UDF getdefaultPrinter is in the udf library collection.

and shorter version:
http://www.kixtart.org/UDF/UDF_lister.php?what=post&code=117544
_________________________
!

download KiXnet

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 507 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.186 seconds in which 0.109 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org