I am using the below script to install a network printer. For XP, the script is working fine but when I tried to run it on a Windows 7 machine. It gives me an error. Can help to check it out? The
driver is found on a network drive.
I also need this to work with only user access rights.
Quote:
PathToDLL = "\\..\Command\PRNADMIN.DLL"
portloc = "10...."
DriverName = "FX DocuCentre-IV C4470 PCL 6"
PrintQueueName = "FX DocuCentre-IV C4470 PCL 6"
set wshshell = wscript.createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
fso.copyfile PathToDLL, "\\..\Command\PRNADMIN.DLL", True
wshshell.run "regsvr32 /s ""\\...\selfhelp\Command\PRNADMIN.DLL""", , True
wscript.sleep 1000
dim oPort
dim oMaster
set oPort = CreateObject("Port.Port.1")
set oMaster = CreateObject("PrintMaster.PrintMaster.1")
portinput = "IP_" & portloc
oPort.ServerName = ""
sPortExist = False
for each oPort in oMaster.Ports("")
if oPort.PortName = portinput then
sPortExist = True
End If
next
If sPortExist = False then
set oPort = CreateObject("Port.Port.1")
oPort.PortName = portinput
oPort.PortType = 2
oPort.HostAddress = portloc
oPort.PortNumber = 9100
oPort.QueueName = "lp"
oPort.DoubleSpool = true
oPort.SNMP = false
oMaster.PortAdd oPort
if Err <> 0 then
msgbox "an error occurred"
end if
End If
dim oPrinter
set oPrinter = CreateObject("Printer.Printer.1")
oPrinter.DriverPath = "\\...\FX DocuCentre-IV C4470\Win2000_XP"
oPrinter.InfFile = "\\...\FX6KYAL.inf"
oPrinter.ServerName = ""
oPrinter.PrinterName = PrintQueueName
oPrinter.DriverName = DriverName
oPrinter.PortName = portinput
oMaster.PrinterAdd oPrinter
if Err.number <> 0 then
msgbox "an error occurred"
Else
msgbox "Printer Installed Successfully"
End If
set oport = nothing
set oPrinter = nothing
set oMaster = nothing
set wshshell = nothing
set fso = nothing