The most important bit if information that you need is the reason *why* the printer is not being added.

You can find this information in two places. Firstly, if the printer mapping is failing then there will almost certainly be entries in the event logs - check both System and Application logs.

Secondly, the command itself will tell you why the mapping failed. It's not always the complete answer, but it will often give you a clue.

Try something like this:
 Code:
If InGroup('group name')
	If AddPrinterConnection('\\server\sharename')
		"ERROR: Failed to add printer, reason: ["+@ERROR+"] @SERROR"+@CRLF
	Else
		"Printer added successfully"+@CRLF
	EndIf
EndIf


This will tell you a couple of things.
  • If the printer is added OK you will get a message confirming it.
  • If the printer add fails you will get a message telling you what the error code was. It might be a bit obtuse, for example "[5] Access denied" can be caused by a lot of different problems, but at least it will give you a clue where to look next.
  • It is possible that you will get no message - in this case you know that the problem is in the InGroup()


Don't forget to check the event logs though - the messages in there are usually more informative.