Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


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


06 Sep 2012   #1

Windows 7 Ultimate x64
 
 
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




Thread Tools



Similar help and support threads for2: 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
Printer sharing on mixed OS network (XP/Win7) 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
Brother HL-2140 Printer Not Working w/ Win7 Hardware & Devices

Our Sites

Site Links

About Us

Find Us

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

All times are GMT -5. The time now is 01:36 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33