Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Re: 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 >> Re: Add Network Printer As LocalPort
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2] 3   next >   >>
Login
Message << Older Topic   Newer Topic >>
 Re: Add Network Printer As LocalPort - 3/20/2005 8:12:11 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
now i must ask: what is your purpose with achieving that?

Printing thru the Printserver is easier then to let everybody run the printer thru the LPT, mainly because if something is not spooling, then you only would have to restart the spooler at the server. Printer thru the server is also faster and more stable, because the jobs run off the network in stead of their own PC, where they need the CPU for their daily chores, in stead of an additional load of printing

That's is one of the purposes of putting the printer on the network....

[8)]

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

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Snipah: Thanks for the reply. The main reason we do it that way is because we use roaming profiles and when another user logs on to a computer in a different building or floor we want them to have the printers that were there already and not the printers that would be in there profile.

Cheers for your help so far

(in reply to cjwallace)
 
 
Post #: 22
 
 Re: Add Network Printer As LocalPort - 3/20/2005 8:30:37 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
ah, i see...

I need to further work this out, because i once struggled with the same issue, only I let the end-user decide which printer they use if they login elsewhere....cheap escape, i know....

i'ma get back on it if i find something workable....

[8)]

(in reply to cjwallace)
 
 
Post #: 23
 
 Re: Add Network Printer As LocalPort - 3/20/2005 8:33:38 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Snipah: Thanks for the reply, im glad someone knows where i am coming from on this issue, i was starting to think noone understood my problem. If you do think of any way of doing it please let me know

Thanks for your input so far mate

(in reply to cjwallace)
 
 
Post #: 24
 
 Re: Add Network Printer As LocalPort - 3/20/2005 11:52:15 AM   
  tnoonan

 

Posts: 364
Score: 0
Joined: 12/14/2004
From:
Status: offline
cjwallace there are three ways to map a printer soft map, hard map, and static map. Token and I have shown you all three. Only one will show for any user who logs in to the pc and that is static map. Or you can use soft or hard map if you write a script and put it in the hklm\software\microsoft\windows\currenversion\run so it will apply to all users.

(in reply to cjwallace)
 
 
Post #: 25
 
 Re: Add Network Printer As LocalPort - 3/20/2005 8:08:55 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Snipah: Hello mate, i have just tried your suggestion with adding the printers as LPT ports. It seems you can only run 1 printer off one LPT port which is no good for us becuase our users tend to have about 10 printers per computer setup.

I will struggle on with my issue

Thanks for your help

(in reply to cjwallace)
 
 
Post #: 26
 
 Re: Add Network Printer As LocalPort - 3/21/2005 10:23:11 PM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
CJWallace, thx for the update

(in reply to cjwallace)
 
 
Post #: 27
 
 Re: Add Network Printer As LocalPort - 3/28/2005 5:12:01 AM   
  Reginaldo

 

Posts: 2
Score: 0
Joined: 3/28/2005
From:
Status: offline
Is this what you want?

Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\MyPrinter"
WshNetwork.AddWindowsPrinterConnection PrinterPath

Presumes you're using some sort of SMB print server

(in reply to cjwallace)
 
 
Post #: 28
 
 Re: Add Network Printer As LocalPort - 3/28/2005 5:22:13 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Reginaldo: no...read below:
1)
quote:
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?


2)
quote:
The main reason we do it that way is because we use roaming profiles and when another user logs on to a computer in a different building or floor we want them to have the printers that were there already and not the printers that would be in there profile.



(in reply to cjwallace)
 
 
Post #: 29
 
 Re: Add Network Printer As LocalPort - 3/28/2005 7:17:35 AM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Reginaldo, Sniphah, thanks for both your replys.

I am still no closer to fixing my issue

(in reply to cjwallace)
 
 
Post #: 30
 
 Re: Add Network Printer As LocalPort - 3/28/2005 7:26:56 AM   
  Reginaldo

 

Posts: 2
Score: 0
Joined: 3/28/2005
From:
Status: offline
I suggest one of three approaches if you don't want printers to follow user profiles:

A) use group policy (if you're using AD)
run a script which installs a set of printers for the PC, depending on its location (stored in AD) or put machines into AD groups (E.G. "Print 2nd floor", "Print 3rd floor"). Write a script to figure out if the Computer (NOT USER) is in the group and map printers accordingly.

B) Write one script which checks computer name or IP subnet and then maps printers depending on the computer name. Not sure how you know which machine is in which location, I'll leave that up to you.

C) do what tnoonan said. It's a perfectly reasonable solution.

In case A or B, you may want to remove all mapped printers prior to mapping any new ones.

Mapping any printer, network, local or otherwise has been posted in this thread already.

(in reply to cjwallace)
 
 
Post #: 31
 
 Re: Add Network Printer As LocalPort - 3/28/2005 6:55:52 PM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
quote:
Originally posted by Reginaldo

I suggest one of three approaches if you don't want printers to follow user profiles:

A) use group policy (if you're using AD)
run a script which installs a set of printers for the PC, depending on its location (stored in AD) or put machines into AD groups (E.G. "Print 2nd floor", "Print 3rd floor"). Write a script to figure out if the Computer (NOT USER) is in the group and map printers accordingly.




Couldn't agree more on the AD part, only, not all corporations have that yet implemented (financial boundaries, implementation time, yada yada yada)

Until so far... CJWallace, i think (for now) what you try to achieve is impossible.

(in reply to cjwallace)
 
 
Post #: 32
 
 Re: Add Network Printer As LocalPort - 4/6/2005 12:33:57 PM   
  canz

 

Posts: 3
Score: 0
Joined: 4/6/2005
From: New Zealand
Status: offline
Hello all, I've never done any scripting before so have little clue on how to do it. But never too old to learn!
I managed to run a script to add a network printer and make it default, but now I want to add printers onto workstations using a local TCP/IP port (192.168.3.9). I tried the script that was earlier in this thread (also from the MS scripting centre) but it doesn't work -
ERROR:
addport.vbs
Line: 1
Char: 1
Error: 0x80041021
Code: 80041021
Source: (null)

Can I run this script by just double clicking on the .vbs filename or do I have to do something else?

(in reply to cjwallace)
 
 
Post #: 33
 
 Re: Add Network Printer As LocalPort - 4/7/2005 11:40:16 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
If I remember correctly, one of the class used/posted in this thread requires XP (or higher) to install a new TCP/IP port. What OS do you have ? and could you post the script again ?

(in reply to cjwallace)
 
 
Post #: 34
 
 Re: Add Network Printer As LocalPort - 4/7/2005 12:37:29 PM   
  canz

 

Posts: 3
Score: 0
Joined: 4/6/2005
From: New Zealand
Status: offline
I tried it on Win2K & XP, neither worked - same error.
What we are trying to do is push (or pull from client) printers with all the Accessories (Finisher, added Trays etc). Tried to use PrintMigrator but you need Admin rights on local Workstation for it to run - bugger, that won't be good enough.
I think you can copy registry settings that have been changed then deploy them, but that may be too scary for some Administrators - cowards!!
If any of you can help that would be great. There must be a way to write a script to add printers then add accessories.

(in reply to cjwallace)
 
 
Post #: 35
 
 Re: Add Network Printer As LocalPort - 4/8/2005 4:54:47 PM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Could you post the script.

(in reply to cjwallace)
 
 
Post #: 36
 
 Re: Add Network Printer As LocalPort - 4/12/2005 11:12:39 AM   
  canz

 

Posts: 3
Score: 0
Joined: 4/6/2005
From: New Zealand
Status: offline
Here is script one: Error,
Line: 1
Char: 1


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_


Script two:

I got this to work but only for a local port, not a TCP/IP port. Don't know how to change it to create a TCP port, couldn't find resources on "how to".

'******** Register prnadmin.dll file on client computer *******

Set WshShell = Wscript.CreateObject("Wscript.Shell")

WshShell.Run "regsvr32 /s \\w2kserver\winnt\Prnadmin.dll",1,TRUE

'************** Create the port first *******************************

dim oPort

dim oMaster

set oPort = CreateObject("Port.Port.1")

set oMaster = CreateObject("PrintMaster.PrintMaster.1")

oPort.PortName = "Test"

oPort.PortType = 3

oMaster.PortAdd oPort

if Err <> 0 then

msgbox "There was an error creating the port."

end if

'********************************************************************

'************** Create the printer second ***************************
'Change MyPrinter to the name of the printer that you are adding.
'Change PrinterDriver to the name of the printer driver that you are adding.


dim oPrinter

set oPrinter = CreateObject("Printer.Printer.1")

oPrinter.PrinterName = "TestPrn" ' name of the printer as it appears in the Printers folder

oPrinter.DriverName = "afico 340" ' name that is referenced in ntprint.inf

oPrinter.PortName = "Test" ' Specify a port name. Can also point to LPT or COM port.

oMaster.PrinterAdd oPrinter
If Err <> 0 then

msgbox "There was an error creating the printer."

end if

'********************************************************************

'************** Create the directory third ***************************

Dim filesys

Set filesys = wscript.createobject("Scripting.FilesystemObject")

filesys.CreateFolder "C:\MyFolder\" ' Create a folder as a repository for the faxes.

If Err <> 0 then

msgbox "There was an error creating the MyFolder folder."

end if

'********************************************************************

msgbox "The script is finished."

(in reply to cjwallace)
 
 
Post #: 37
 
 Re: Add Network Printer As LocalPort - 4/12/2005 11:30:58 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
For script1, Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

What value does the strComputer hold ?

For script2, what error do you get when you try to install an TCP/IP port/printer ? For simplicity, why don't you just install a TCP/IP printer on a print server and when you map it using network.AddWindowsPrinterConnection, it should be mapped as TCP/IP printer.

(in reply to cjwallace)
 
 
Post #: 38
 
 Re: Add Network Printer As LocalPort - 4/12/2005 10:11:39 PM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
the Set objWMIService = GetObject-line MUST be written in one line, to be most effective!


(in reply to cjwallace)
 
 
Post #: 39
 
 Re: Add Network Printer As LocalPort - 4/13/2005 7:14:07 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I WONDER what's the deal with TCP/IP printers nowadays. Any ideas ?

(in reply to cjwallace)
 
 
Post #: 40
 
 
Page:  <<   < prev  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 >> Re: Add Network Printer As LocalPort Page: <<   < prev  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