Page 1 of 1 1
Topic Options
#198046 - 2010-03-12 02:43 PM map printer add exception
shaneblues Offline
Fresh Scripter

Registered: 2010-03-05
Posts: 5
Loc: UK
I have a script which adds printers based on AD groups, I seem to remember that I could add exceptions so that certain members of the group would not get the default printer.I could then set there default printer to another one from the list , but I cannot remember how to do this please help,
thanks,
Shane.


; ------------------------------------------------------------------
;Map Printer
; ------------------------------------------------------------------
If InGroup("All_Staff")
AddPrinterConnection("\\$PRINTSERVER\Classroom Color")
AddPrinterConnection("\\$PRINTSERVER\Reception B&W Double Sided")
AddPrinterConnection("\\$PRINTSERVER\Reception Printer HP Universal Printing PCL 5")
AddPrinterConnection("\\$PRINTSERVER\Reception HP Universal Printing PCL 6 (v5.0)")
AddPrinterConnection("\\$PRINTSERVER\Reception HP Color LaserJet CM6030 MFP PCL 6 new driver")
SetDefaultPrinter("\\$PRINTSERVER\Reception Printer HP Universal Printing PCL 5")
Endif

Top
#198048 - 2010-03-12 03:16 PM Re: map printer add exception [Re: shaneblues]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
Have a look at the script below.

 Code:
; ------------------------------------------------------------------
;Map Printer
; ------------------------------------------------------------------
If InGroup("All_Staff")
	$rc = AddPrinterConnection("\\$PRINTSERVER\Classroom Color")
	$rc = AddPrinterConnection("\\$PRINTSERVER\Reception B&W Double Sided")
	$rc = AddPrinterConnection("\\$PRINTSERVER\Reception Printer HP Universal Printing PCL 5")
	$rc = AddPrinterConnection("\\$PRINTSERVER\Reception HP Universal Printing PCL 6 (v5.0)")
	$rc = AddPrinterConnection("\\$PRINTSERVER\Reception HP Color LaserJet CM6030 MFP PCL 6 new driver")
	If @USERID <> "Usernamegoeshere"
		$rc = SetDefaultPrinter("\\$PRINTSERVER\Reception Printer HP Universal Printing PCL 5")
	EndIf
EndIf
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#198052 - 2010-03-12 04:33 PM Re: map printer add exception [Re: Mart]
shaneblues Offline
Fresh Scripter

Registered: 2010-03-05
Posts: 5
Loc: UK
thanks for that I have added it to my script and will test on users PC ,
what dose the $rc do
Shane.

Top
#198054 - 2010-03-12 04:42 PM Re: map printer add exception [Re: shaneblues]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
$rc will catch the return code of AddPrinterConnection and SetDefaultPrinter. Both functions will give you return codes and they will show on the user's screen. Putting $rc = in front of the function will prevent the return codes from being displayed. It’s not required but it looks nicer for the user.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#198055 - 2010-03-12 04:43 PM Re: map printer add exception [Re: shaneblues]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Functions may return a value, sometimes it is related to the function purpose and sometimes it is a status value.

You may choose to ignore the status value because the action is trivial and you will detect a failure another way, usually by your user 'phoning up and complaining ;\)

If you don't do anything with the return code it will appear on the console by default, so you end up with a string of zeros and ones appearing. $RC is a a variable (you can use any variable you like) which is just catching the return value so that it doesn't appear on the screen.

In well written scripts you will check the return value and act on failures.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 384 anonymous users online.
Newest Members
SERoyalty, mytar, Gabriel, Alex_Evos, Dansen
17869 Registered Users

Generated in 0.053 seconds in which 0.024 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