Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with printer vbscript

Status
Not open for further replies.

patrichek

MIS
Nov 18, 2003
632
0
0
US
Hi all,
I made a vbscript to add a network printer to an OU containing computers. the script will work if i click on it at a workstation but not by gpo. I added the vbs to the user config. windows settings, logon scripts in the gpo. any ideas?
thanks!
 
Can you show the script you made?

I use a Vbs script to do the same and attach it to the logon scripts area of my users GPO.

Network.AddwindowsPrinterConnection "\\Server\HP4050"
Network.SetDefaultPrinter "\\Server\HP4050"

That works fine for me.
 
here it is and i add it in the same place you described. the only difference is i don't use the defaultprinter line, its a backup printer.

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\server\printername"

i saw a post somewhere that suggests i add obj to the script? i haven't tried that yet.
 
that's where i got it! :)

' VBScript.' Guy Thomas February 2004.
'
' Purpose of script to create a local printer
' ******************************

Dim net
Set net = CreateObject("WScript.Network")
net.AddWindowsPrinterConnection "\\ServerName\PrinterName"
 
I think I got mine from Technet but I can't find where to give you the link, anyway I assure the code i pasted works flawlessly we have 1500 users roaming between various PC's and it adds them every time.

Look here for a bit more detail.

thread94-910564
 
Does it add to a specific room or do users collect printers as they go?

We use a local script to connect a room's printers and would prefer to make this far more central.
 
It adds the appropriate printer for the room the user is in at logon based to the machine name, so PC names need to be room based eg IT1_PC1

Thread94-910564
 
So your script also contains code that identifies the machine name? Could you not simply add it to the OU for the room?
 
Well this way i can just add the script in one place for all users so it's easy to make changes as i just alter the script, it incures very little overhead to manage them this way.

Set Network = CreateObject("Wscript.Network")
compname = network.computername
room = left(compname,3)

Select Case room
Case "D29"

The D29 bit is the first three charectors of the PC name.
 
and then you have it as a logon script for all users within the GPO?

I like it...
 
ok guys, i got it. I had assigned the gpo to computers the first time around, i assigned it to the user ou and its working.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top