Page 1 of 1 1
Topic Options
#211870 - 2016-08-10 10:38 PM Looking for help with SETDEFAULTPRINTER and INGROUP
RyanASP Offline
Just in Town

Registered: 2016-01-29
Posts: 3
Loc: South Charleston, WV
Here's my script:
 Code:
? "Adding Printers"

IF $Printerlist <> ""
 $Printerarray = SPLIT($Printerlist, ",", -1)
 For each $printer in $printerarray

  IF @INWIN = 1
	IF ADDPRINTERCONNECTION("\\$Printserver\$printer") = 0 
		? "Successfully added printer: $printer"
	ENDIF

	IF INGROUP("TS $printer")
		IF SETDEFAULTPRINTER("\\$Printserver\$printer") = 0
			? "Default printer set to: $printer"
		ENDIF
	ENDIF

  ENDIF
 Next
 ?
ENDIF


? "End Printer Add"


We recently moved from a 2003 server to a 2012...both on our domain and terminal server. The script goes through and adds the servers just fine, but keeps defaulting all users to the same printer no matter which group they are in. It almost "feels" like it's not seeing their group membership. I added an ENUMGROUP and sure enough, it comes back with nothing. The ENUMGROUP bit I added was actually the example from the manual, and it returns nothing at all. The users know how to set their default printer and choose off the print dialog list, but it's frustrating to say the least. Anyone have any help?


Edited by Allen (2016-08-10 10:45 PM)

Top
#211871 - 2016-08-10 10:53 PM Re: Looking for help with SETDEFAULTPRINTER and INGROUP [Re: RyanASP]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
I always forget whether the setdefault, addprinter, and delprinter functions need the share name, the printer name, or whatever. Many around here religiously name the printers and the share name, the exact same thing so that it is not an issue. Personally, I like using the share name and wrote a function to get around not being able to do this. Your choice, but I would start in these two places.

PrinterConnection has the ability to add, del, set and determine the default printer, all using the same share name. Examples are in the header of the UDF.

PrinterConnection -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=203840#Post203840

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1





_________________________
(... better days ahead)

Top
#211872 - 2016-08-11 03:58 AM Re: Looking for help with SETDEFAULTPRINTER and INGROUP [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Did you change groupnames when you were at it? Although enumgroup will always return something for every domain user, still had to ask...

Setdefaultprinter needs \\server\printername

If your printer name is not exactly the same as your sharename, your script would indeed fail on that part


Edited by Lonkero (2016-08-11 02:40 PM)
Edit Reason: spell check
_________________________
!

download KiXnet

Top
#211873 - 2016-08-11 09:38 AM Re: Looking for help with SETDEFAULTPRINTER and INGROUP [Re: Lonkero]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
At the beginning of the printers script add this line:
 Code:
$=WriteValue('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows','Device','winspool,Ne00:')

This removes the current default printer.
Also, check for @ERROR after this line, if there is an @ERROR then the permissions on that registry setting is wrong causing your initial problem.

Top
#211874 - 2016-08-11 09:49 AM Re: Looking for help with SETDEFAULTPRINTER and INGROUP [Re: Allen]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: Allen

....
Many around here religiously name the printers and the share name, the exact same thing so that it is not an issue.
....


Guilty as charged \:D and I would do it again when needed

If group names have changed then you might want to clear the KiXtart token cache. We did the same swap a few months ago and did not encounter any issues. That might have been because we have the printer names and share names exactly the same or because at that time we intentionally set the KiXtart token cache to be cleared every time at login. Yes this makes logon a little bit slower but there was a valid need to do this at that time.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

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 1383 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.056 seconds in which 0.025 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