|
|
|||||||
Hi, I´m on my way to migrate our exiting domain to another. For conneting shares and printers I´d like to us kix. As connecting to shares and printers works well. but not set them up as default. I´d like to to set the default printers by group. Is this possible? Here my scipt snippet: this workes: Code: IF INGROUP("G_IT") ADDPRINTERCONNECTION ("\\"+$PrintServer+"\printer1") = 0 EndIf this not: Code: IF INGROUP("G_IT") SetDefaultPrinter ("\\"+$PrintServer+"\printer1") = 0 Endif Thanks |
||||||||
|
|
|||||||
Kix uses the share name for some functions and the printer name for others. I didn't like have to remember which was which or name the printers and the share name the same thing. Both are options. The third option is to use the UDF PrinterConnection. Everything is controlled by one function and the share name. 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 |
||||||||
|
|
|||||||
Hi, thanks for your answer. To be honest I`m really new in kix scripting, and i really want to keep it simple. I´ve read the links but I don´t get it. Maybe some has an example? Goal is really only: Connect Printer if user is in a specific AD Group, and set this printer as default. I´ve tried the default with diffrent printernames: Sharename, Windows Printername, Printer discription and even with the port number. Didn´t work. Thanks |
||||||||
|
|
|||||||
Something simple as this should work. Please keep in mind that the AddPrinterConnection function requires the share name of the printer (something like \\server\printer01) and SetDefaultPrinter requires the name of the printer (HP LaserJet Finance for example). To avoid issues with adding printers and setting them as default I always keep the printer name and the share name exactly the same. This is not a requirement but it makes things a heck of a lot easier. Code: Break on If InGroup("AD_groupname") $rc = AddPrinterConnection("\\Server\PrinterShareName") ? @ERROR ? @SERROR $rc = SetDefaultPrinter("Printername") ? @ERROR ? @SERROR Else ? "User " + @USERID + " is not in the correct AD group" EndIf |
||||||||
|
|
|||||||
I use groups to set printers. There needs to be a naming convention used for this script to work. All printers have two matching groups Ex Printer name q-mis Ex Group name A01_q- D01_q- A02_q- D02_q- 2 groups for this printer on print server 1: A01_q-mis and A01_q-mis 2 groups for this printer on print server 2: A02_q-mis and A02_q-mis Code: ********** Beginning of printer mapping ********* call @Scriptdir+'\primapstate.udf' $WS = GetObject('WinNT://' + @domain + '/' + @wksta + '$$') if @error ? @serror else $ps1='prn01' ; site1 ps1 $ps2='prn02' ; site2 ps2 $ps3='oma-prn01' ; site3 ps1 $ps4='oma-prn02' ; site3 ps2 $ps5='pro-prn01' ; site4 for each $grp In $WS.Groups $GrpName = $grp.Name ;--- Add additional printers --- if left($GrpName,2) = 'A0' ; $psn = substr($Grpname,2,2) ;print server number determined by 2-3 character A01=PS1 A02=PS2 if $psn='01' $ps=$ps1 endif if $psn='02' $ps=$ps2 endif if $psn='03' $ps=$ps3 endif if $psn='04' $ps=$ps4 endif if $psn='05' $ps=$ps5 endif $addlprinter = substr($GrpName,5) ;printer group name starts at 5th character $addlprinter = $ps+'\'+$addlprinter $addlprinter = '\\'+$addlprinter ? "Additional Printer: "$addlprinter if not PriMapState($addlprinter) ? "Status: Printer not connected " + $addlprinter $nul=AddPrinterConnection($addlprinter) ? "Status: Printer added " + $addlprinter ? @serror endif endif ;--- Add and set default printer --- if left($GrpName,2) = 'D0' ;print server number determined by third character D01=PS1 D02=PS2 $defprinter = substr($GrpName,5) ;printer group name starts at 5th character $psn = substr($Grpname,2,2) if $psn='01' $ps=$ps1 endif if $psn='02' $ps=$ps2 endif if $psn='03' $ps=$ps3 endif if $psn='04' $ps=$ps4 endif if $psn='05' $ps=$ps5 endif $defprinter = $ps+'\'+$defprinter $defprinter = '\\'+$defprinter ? "** Printers assigned through Printer Setup Group **" ? " " ? "Default Printer: "$defprinter if not PriMapState($defprinter) ? "Status: Printer not connected "+$defprinter $nul=AddPrinterConnection($defprinter) ? "Status: Printer added "+ $defprinter ? @serror $nul=SetDefaultPrinter($defprinter) ? "Status: Default Printer set "+ $defprinter ? @serror endif if PriMapState($defprinter)<>2 $nul=SetDefaultPrinter($defprinter) ? "Status: Default Printer changed "+ $defprinter ? @serror endif endif next endif |