Add Network Printers Automatically

Hi there,

I am quite new to the Applecript, but I have some experience in php and HTML. I’m trying to create a script/batch file that installs a network printer automatically.

Unfortunately, my script adds the printer, but it doesn’t work! :frowning:

Can anyone give me some input? The information in the printer is the same as if I add it manually. But to add it manually, I have to add the advanced icon in the header of the add printer dialog.

This is my script so far

 set thePrefix to ""
set Username to ""
set printerpass to ""
set theIcon to note
repeat
	display dialog thePrefix & "Please enter your HULT Online Username:" default answer Username with icon theIcon
	set Username to text returned of result
	try
		if Username = "" then error
		set Username to Username
		exit repeat
	on error
		set thePrefix to "INVALID ENTRY! "
		set theIcon to stop
	end try
end repeat

repeat
	display dialog thePrefix & "Please enter your current HULT E-Mail Password:" default answer printerpass with icon theIcon
	set printerpass to text returned of result
	try
		if printerpass = "" then error
		set printerpass to printerpass
		exit repeat
	on error
		set thePrefix to "INVALID ENTRY! "
		set theIcon to stop
	end try
end repeat
-- display dialog "Thank you for entering the Username " & Username & " and password " & printerpass & "."

do shell script "lpadmin -p HULT_Printer -v smb://" & Username & ":" & printerpass & "@192.168.40.6/Hult_Printer_Mac -P /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd"

Any help is HIGHLY appreciated :slight_smile: