Page 1 of 1 1
Topic Options
#63491 - 2002-03-01 07:35 PM setdefaultprinter
Anonymous
Unregistered


I have a user that is part of a group which is having a default printer set by kix. Without creating another group for this person, I would like to change a specific user's printer to default to their local printer instead of the network like the rest of the group. Is this possible? Here is the script we are currently using. What would I add to allow this specific person to have their local printer as their default instead? I thought about using @userid but didn't know how or where... HELP!

If InGroup( "Accounting" )
AddPrinterConnection ("\\server\AcctHP8")
AddPrinterConnection ("\\server\Purchasing HP 2250 Color")
SetDefaultPrinter ("\\server\Accounting HP 8100")
EndIf

Top
#63492 - 2002-03-01 10:40 PM Re: setdefaultprinter
BDA Offline
Lurker

Registered: 2002-02-07
Posts: 4
here's an option. create a system environment variable (ie: DefaultPrinter), and set it's value to the name of the printer you'd like to set as default. then use this script to read that value & set your default printer:

$ValueName = READVALUE("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment","DefaultPrinter")
IF @ERROR = 0
SETDEFAULTPRINTER ("\\LocalComputer\"+$ValueName)
ENDIF

hope that helps.
-BDA

Top
#63493 - 2002-03-03 07:41 AM Re: setdefaultprinter
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Very strange is the way of using AddPrinterConnection and SetDefaultPrinter.
To set the printer default in a correct way the printer should exist. In
your code you add two different printers which doesn't match the default
printer.
The see the actual problem use following code:

code:

IF Ingroup("Accounting") <>0)
IF (AddPrinterConnection("\\server\AcctHP8") <> 0)
? "Warning KIX-AddPrinterConnection: error @error (@serror)"
ELSE
? "Informative KIX: add printer '\\server\AcctHP8'"
ENDIF
IF (AddPrinterConnection("\\server\Purchasing HP 2250 Color") <> 0)
? "Warning KIX-AddPrinterConnection: error @error (@serror)"
ELSE
? "Informative KIX: add printer '\\server\Purchasing HP 2250 Color'"
ENDIF
IF (SetDefaultPrinter("\\server\Accounting HP 8100") <> 0)
? "Warning KIX-SetDefaultPrinter: error @error (@serror)"
ELSE
? "Informative KIX: set defaultprinter ..."
ENDIF
ENDIF


greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#63494 - 2002-03-05 10:25 PM Re: setdefaultprinter
Auke Offline
Fresh Scripter

Registered: 2002-01-31
Posts: 33
Loc: Purmerend, The Netherlands
MCA,

I disagree with you. Gjaquay is right here. To set the default printer you have to select it by its name not the sharename, unless the sharename is the same as the name of the printer.

[ 05 March 2002, 22:25: Message edited by: Auke ]
_________________________
Greetz AukeB

Top
#63495 - 2002-03-05 11:53 PM Re: setdefaultprinter
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why don't you do this:
code:
If InGroup( "Accounting" )
$retcode=AddPrinterConnection ("\\server\AcctHP8")
$retcode=AddPrinterConnection ("\\server\Purchasing HP 2250 Color")
$retcode=SetDefaultPrinter ("\\server\Accounting HP 8100")
If @USERID='specialuser'
$retcode=SetDefaultPrinter ("\\computer\Special Printer")
EndIf
EndIf

_________________________
There are two types of vessels, submarines and targets.

Top
#63496 - 2002-03-11 07:10 AM Re: setdefaultprinter
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear Auke,

We are only using Ruud's example with some modifications.
Of course another way of calling can work, but when we are reading
Gjaquay's code it looks very confusion when you add two printers
like "AcctHP8" and "Purchasing HP 2250 Color" and set "Accounting HP8100"
as default printer.
Code doesn't tell me "AcctHP8" and "Accounting HP8100" are the same
printers. So we doesn't know this "Accounting HP8100" wasalready
defined.
greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
Page 1 of 1 1


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

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.116 seconds in which 0.062 seconds were spent on a total of 12 queries. Zlib compression enabled.

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