I was just coming on here to post some similar findings myself. We have been using Kixtart for 20 years now and continue to use it for adding printers, among other things. Over the past few months we have seen an increased number of complaints with printers not showing up. When we run the scripts after they are already logged in the printers always just load right up no problems at all.

Through some debug logging I've find that on some occasions the ADDPRINTERCONNECTION fails with error 87. According to https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- error 87 is just "The parameter is incorrect" which is not helpful. I have found that if I see that error, wait 5 seconds, and then try again it works fine.

Looking at the logs for a group of machines I did testing on I'd say 50% or more of people logging in get the printers no problem on try #1. The rest get error 87 on the first try and then consistently the second try works fine. I modified my AddPrinterFunction as follows to work around the problem:

FUNCTION AddPrinter_IfNOTExist($_printer, OPTIONAL $_Default)
	$AddPrinter_IfNOTExist = 0
	$found = 0
	$add_printer_attempts = 0
	$add_printer_max_retries = 3
	$_Default = Val($_Default)
	$ret = ReadValue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices", $_printer)
	IF @ERROR = 0 $found = 1 ENDIF
	IF $found = 0
			$add_printer_attempts = $add_printer_attempts + 1
			$AddPrinter_IfNOTExist = ADDPRINTERCONNECTION($_printer)
			IF $add_printer_attempts < $add_printer_max_retries
				;retry on specific errors
				IF $AddPrinter_IfNOTExist = 87
					SLEEP 5
					$add_printer_attempts = $add_printer_max_retries + 1
		UNTIL $AddPrinter_IfNOTExist = 0 OR $add_printer_attempts >= $add_printer_max_retries
		IF $_Default = 1 AND $AddPrinter_IfNOTExist = 0
			$ret = SETDEFAULTPRINTER($_printer)