backfight
(Getting the hang of it)
2007-01-22 08:49 AM
ADDPRINTERCONNECTION does not work

Hi all,
i have a problem with the ADDPRINTERCONNECTION command. I wanna map 2 Printers to a special group. Can someone post me the code here? I´ve tested so many codes but nothing works. How does it work to get an error when the connection to the printer is failed?

PS: Sorry for my bad english but i´m from germany

Best wishes

Backfight


Witto
(MM club member)
2007-01-22 09:44 AM
Re: ADDPRINTERCONNECTION does not work

Code:
;Script Options
If NOT @LOGONMODE
	Break On
EndIf
Dim $RC
$RC=SetOption("Explicit", "On")
$RC=SetOption("NoMacrosInStrings", "On")
$RC=SetOption("NoVarsInStrings", "On")
$RC=SetOption("WrapAtEOL", "On")
;Map Printer
If InGroup("GroupName")
	$RC = AddPrinterConnection("\\Servername\PrinterShareName")
EndIf


backfight
(Getting the hang of it)
2007-01-22 10:07 AM
Re: ADDPRINTERCONNECTION does not work

Hello there,
thanks for the early answer. But it doesn´t work. What i´m making worng? What must be configured on the server so that that script work Coretly?

Thanks for your help

Best wishes

Backfight


Richard H.Administrator
(KiX Supporter)
2007-01-22 10:38 AM
Re: ADDPRINTERCONNECTION does not work

I've amended Witto's code so that it returns an error if the mapping fails:
Code:
;Script Options
If NOT @LOGONMODE
	Break On
EndIf
Dim $RC
$RC=SetOption("Explicit", "On")
$RC=SetOption("NoMacrosInStrings", "On")
$RC=SetOption("NoVarsInStrings", "On")
$RC=SetOption("WrapAtEOL", "On")
 
Dim $sPrintServer	$sPrintServer="ServerName"
Dim $sPrinterName	$sPrinterName="PrinterName"
 
;Map Printer
If InGroup("GroupName")
	$RC = AddPrinterConnection("\\"+$sPrintServer+"\"+$sPrinterName)
	If @ERROR "ERROR: Cannot map printer "+$sPrinterName+" on "+$sPrintServer+" Reason: ["+@ERROR+"] "+@SERROR+@CRLF EndIf
EndIf


Make sure that the printer name and the share name are identical on the print server, otherwise it will cause you problems.


backfight
(Getting the hang of it)
2007-01-22 11:29 AM
Re: ADDPRINTERCONNECTION does not work

Yes! It works!Thanks a lot!

But there comes a beep! Does this mean there is an error?


backfight
(Getting the hang of it)
2007-01-22 11:58 AM
Re: ADDPRINTERCONNECTION does not work

now the only thing i need is the command to set one of the printers to default printer

Björn
(Korg Regular)
2007-01-22 12:13 PM
Re: ADDPRINTERCONNECTION does not work

All the commands is in the command reference.

backfight
(Getting the hang of it)
2007-01-22 12:46 PM
Re: ADDPRINTERCONNECTION does not work

Yes but how to code it in this especial example?
Sorry but i´m a newbie in kixtart


Witto
(MM club member)
2007-01-22 01:44 PM
Re: ADDPRINTERCONNECTION does not work

$RC = SetDefaultPrinter("\\"+$sPrintServer+"\"+$sPrinterName)

backfight
(Getting the hang of it)
2007-01-22 03:20 PM
Re: ADDPRINTERCONNECTION does not work

Ok and how do i get the printers removed?

Excample: Some user wanna login but he issen´t in a group that gets printers. But he get! How can i say this user must not get any printer?

Thanks 4 Help


Witto
(MM club member)
2007-01-22 05:22 PM
Re: ADDPRINTERCONNECTION does not work

I do not get this one. Printers added with "AddPrinterConnection()" are added per user, not per computer.

DelPrinterConnection()


backfight
(Getting the hang of it)
2007-01-23 08:23 AM
Re: ADDPRINTERCONNECTION does not work

Some users without any dedicated printers get without any reason some printers from another group.

Excample: Group xy get the Printer HP Laserjet 5
Group ab get no Printer
If any user frome group ab is registrated he get without any reason
dedicated one printer from group xy

Hope you understand me right

Sorry 4 my bad english


Witto
(MM club member)
2007-01-23 10:11 AM
Re: ADDPRINTERCONNECTION does not work

There is always a reason. I don't understand it.