Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Add Network Printer As LocalPort

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2347
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Add Network Printer As LocalPort
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2 3   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Add Network Printer As LocalPort - 3/15/2005 2:08:11 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Guys, how can i add a network printer such as \\ntprint1\lgp14m to a local port?
 
 
Post #: 1
 
 Re: Add Network Printer As LocalPort - 3/15/2005 2:15:04 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Is the printer installed? If not you need to install it first ie

objWshShell.Run "rundll32 printui.dll, PrintUIEntry /q /if /b " & """SAVINTELLERS""" & " /f N:\savin\3799\PCL6\WIN2K_XP\oemsetup.inf /r " & """LPT1:""" & " /m " & """SAVIN FAX3799/3799nf PCL 6"""

Then just map it at login ie

WSHNetwork.AddPrinterConnection "LPT1", "\\Server01\SAVINTELLERS"

(in reply to cjwallace)
 
 
Post #: 2
 
 Re: Add Network Printer As LocalPort - 3/15/2005 2:17:07 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi Tnoonan, our printers are all installed on our printer servers so would i need all that script above?

Cheers

(in reply to cjwallace)
 
 
Post #: 3
 
 Re: Add Network Printer As LocalPort - 3/15/2005 2:18:17 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
also we dont want it to be on LPT1 , just a local tcpip printer port

Cheers

(in reply to cjwallace)
 
 
Post #: 4
 
 Re: Add Network Printer As LocalPort - 3/15/2005 5:21:37 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Maybe you should be more specific about what a "local port" is.

set network = createobject("wscript.network")
network.AddWindowsPrinterConnection "\\ntprint1\lgp14m"

Or you can use the Win32_Printer class, which does the same thing.

(in reply to cjwallace)
 
 
Post #: 5
 
 Re: Add Network Printer As LocalPort - 3/15/2005 5:41:47 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
Install printer port

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "IP_169.254.110.14"
objNewPort.Protocol = 1
objNewPort.HostAddress = "169.254.110.14"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_


Then

objWshShell.Run "rundll32 printui.dll, PrintUIEntry /q /if /b " & """SAVINTELLERS""" & " /f N:\savin\3799\PCL6\WIN2K_XP\oemsetup.inf /r " & """IP_169.254.110.14""" & " /m " & """SAVIN FAX3799/3799nf PCL 6"""

(in reply to cjwallace)
 
 
Post #: 6
 
 Re: Add Network Printer As LocalPort - 3/15/2005 8:21:14 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
quote:
Originally posted by token

Maybe you should be more specific about what a "local port" is.


Ok, When i right click on one of our ptinters and clcik properties and then look at the ports tab.

Port
\\ntprint1\lgp14m

Description

Local Port

Printer

LGP14M

They are network printers but they appear to the desktop as a local printer. We dont use them on LPT ports

So how can i add a printer in this way via a .vbs script?

Thanks guys

Look forward to hearing from you

(in reply to cjwallace)
 
 
Post #: 7
 
 Re: Add Network Printer As LocalPort - 3/16/2005 12:34:49 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hi guys, I have this script trying to achive above said issue.

Set objWMIService = GetObject("winmgmts:")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_
objNewPort.Name = "LGP14M"
objNewPort.Protocol = 1
objNewPort.HostAddress = "10.10.2.14"
objNewPort.PortNumber = "9100"
objNewPort.SNMPEnabled = False
objNewPort.Put_

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objPrinter = objWMIService.Get("Win32_Printer").SpawnInstance_
objPrinter.DriverName = "HP 4050 Series"
objPrinter.PortName = "IP_10.10.2.14"
objPrinter.DeviceID = "HP 4050 Series"
objPrinter.Location = "IT"
objPrinter.Network = True
objPrinter.Shared = false
' objPrinter.ShareName = "ScriptedPrinter"
objPrinter.Put_

----------------

But when i run it i get

Script: "Path of Script"

Line: 2

Char: 1

Error: Not Found

Code: 80041002

Source SWbemServices


As i am sure most of you know i am new to VB, so not sure what is going on?

Thanks for your help in advance

(in reply to cjwallace)
 
 
Post #: 8
 
 Re: Add Network Printer As LocalPort - 3/16/2005 2:19:42 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Please delete this post, the above script will only run on windows xp or windows Server 2003

(in reply to cjwallace)
 
 
Post #: 9
 
 Re: Add Network Printer As LocalPort - 3/16/2005 9:54:30 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
You could delete your own, look for the right-most icon (one with recycle bin) and click it.

(in reply to cjwallace)
 
 
Post #: 10
 
 Re: Add Network Printer As LocalPort - 3/17/2005 2:40:13 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Hello guys,

When i run the script below i get an error mesaage

Script "Path to script"
Line: 13
Char: 1
Error: Expected Statement
Code 800a0400
Source: Microsoft VBScript compilation error

----------------------------
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objNewPort = objWMIService.Get _
("Win32_TCPIPPrinterPort").SpawnInstance_

objNewPort.Name = "LGP14M"
objNewPort.Protocol = 1
objNewPort.HostAddress = "10.10.2.14"
objNewPort.PortNumber = "9999"
objNewPort.SNMPEnabled = False
objNewPort.Put_

Then

objWshShell.Run "rundll32 printui.dll, PrintUIEntry /q /if /b " & """SAVINTELLERS""" & " /f N:\savin\3799\PCL6\WIN2K_XP\oemsetup.inf /r " & """LGP14M""" & " /m " & """SAVIN FAX3799/3799nf PCL 6"""

(in reply to cjwallace)
 
 
Post #: 11
 
 Re: Add Network Printer As LocalPort - 3/17/2005 3:41:29 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
TCPIPPrinterPort class is only supported in XP unless you update the Cimwin32.dll file. Why did you even bother asking questions if you don't intend to take the answers ? For the last time, did you even try what I posted earlier ?

(in reply to cjwallace)
 
 
Post #: 12
 
 Re: Add Network Printer As LocalPort - 3/17/2005 7:51:27 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Token: Yes i have tried what you said and yes it works THANKS, but it is not want i want to achive.

As i said before, i want to have a network printer appear to windows as a LOCAL PRINTER

(in reply to cjwallace)
 
 
Post #: 13
 
 Re: Add Network Printer As LocalPort - 3/17/2005 1:12:51 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Could you explain what is a "local printer" and how does it differ EXACTLY from a non-local printer ?

(in reply to cjwallace)
 
 
Post #: 14
 
 Re: Add Network Printer As LocalPort - 3/17/2005 9:05:01 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Token, Ok i will start from Scatch. At the moment we install our network printers on our desktops in this way

Add Printer, Local Printer, Create a new port and select Local Port, When is says enter a port name we would enter for example \\ntprint1\lgp14m , Then we would select the Manufacturers and printer driver , Then we would give the printer a name

Now We run Windows 2000 SP4 and need to find a way to do this via a vbs script.

Does this make things a bit more clear?

Again thanks to you and everyone else who can help

(in reply to cjwallace)
 
 
Post #: 15
 
 Re: Add Network Printer As LocalPort - 3/20/2005 12:21:21 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Guys, can anyone shine some light on my printer port issue

Cheers

(in reply to cjwallace)
 
 
Post #: 16
 
 Re: Add Network Printer As LocalPort - 3/20/2005 6:06:16 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
To add:

      

To Delete

      


(in reply to cjwallace)
 
 
Post #: 17
 
 Re: Add Network Printer As LocalPort - 3/20/2005 6:23:41 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Snipah: Many thanks for your reply mate. Do you know how with a .vb script how to add a network printer as a standard tcpip port?

Also i have not tried it but can you have more than one printer attached to LPT port?

(in reply to cjwallace)
 
 
Post #: 18
 
 Re: Add Network Printer As LocalPort - 3/20/2005 6:37:00 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
1)
TCP/IP (haven't tried it though, normally you use the standard Windows GUI, or the above examples by my fellow Veterans):

NET USE \\ntprint1\lgp14m /persistent:yes


2)
If you have more than one physical port (more parralel ports) then replicate the script with LPT2, LPT3, etc.

(in reply to cjwallace)
 
 
Post #: 19
 
 Re: Add Network Printer As LocalPort - 3/20/2005 7:50:58 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Snipah: Thanks for the reply mate.

Do you know if i had say 20 network printers and set them all up to run off LPT1 would they all work ok? in that i mean could they all print at different times not all in one go?

Again thanks for the reply

(in reply to cjwallace)
 
 
Post #: 20
 
 
Page:   [1] 2 3   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Add Network Printer As LocalPort Page: [1] 2 3   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts