Windows 7 Forums


Windows 7: VBS Script for adding network printer not working on Win7

06 Sep 2012  
blackmenthol

Windows 7 Ultimate x64
8 posts
 
 
VBS Script for adding network printer not working on Win7

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
My System SpecsSystem Spec

Reply

 VBS Script for adding network printer not working on Win7 problems?



Thread Tools



Similar help and support threads for: VBS Script for adding network printer not working on Win7
Thread Forum
Wireless not working after trying to add HP Printer to wifi network Network & Sharing
Solved Printer no longer working on my wirless network Hardware & Devices
Solved Network Printer Install not working!? Network & Sharing
VB Script for Installing Network Printers not working Network & Sharing
add network printer then stop auto adding more printers Network & Sharing


All times are GMT -5. The time now is 04:10 AM.



Windows 7 Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd