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!

Default Printer Help

Status
Not open for further replies.

mcanet

MIS
Aug 5, 2004
15
0
0
US
I am looking for ways to rollout my operating systems with almost no user interaction at all. To this point, I am using ghost with sysprep for my win2000 and xp machines. I am able to via vbscript rename the computer via reverse dns lookup and am now looking at automating the printer install. I am making one ghost image with all the printers installed on it that we own, which is about 10 different makes and models. I'm looking to set the default printer based on the room the computer is in. In each classroom, this is school, I have a bank of 5 or 6 computers and a "teacher" computer that has a local printer that is shared out. As of now we, the techs, manually sit at each computer and configure the port and set the default printer. I'm looking to do this automatically. My idea for now is to install a queue on each server in each building that points to the "teacher computer" and share it out with the room number (\\server\120). And since every computer name contains the room number in the 5th, 6th and 7th character of the name, I would query the computer name from either DNS or the registry, pick out those 3 numbers. And then code \\server\roomnumber as the default printer. But then I got to thinking that I want the default set to the computer regardless of who logs on, and if I'm not mistaken you cannot set a default "network" printer to a computer. At least I have failed in my attempts to do this in the past. So if anyone has any recommendations I would love to hear them. Thanks all in advance.
 
Hi,

I do not know if you have looked at this yet, but this works for me.

Code:
Set objNetwork = CreateObject("Wscript.Network") 
objNetwork.AddWindowsPrinterConnection "\\10.0.0.1\HPLaserJet6MP"
' Set the printer to be the default printer
objNetwork.SetDefaultPrinter "\\10.0.0.1\HPLaserJet6MP"

This will allow the first printer to be added to be a network printer and the default.

Spong
 
The solution Spong has suggested is correct.

You might want to check out my FAQ on login scripts for some ideas. faq329-5798

Working with your suggestion on how you want to do it, here is the solution:

Code:
Set WSHNetwork = CreateObject("WScript.Network")
[green]'Get the PC Name[/green]
StrComputer = WSHNetwork.ComputerName
[green]' Grab the room number[/green]
RoomNum = Mid(StrComputer,5,3)

[green]' Install the printer[/green]
WSHNetwork.AddWindowsPrinterConnection "\\Server\" & RoomNum
[green]' Set the default printer[/green]
WSHNetwork.SetDefaultPrinter "\\Server\" & RoomNum

I hope you find this post helpful.

Regards,

Mark
 
Hi guys thank you so much so far. Just want to clarify two things. Will this work on a computer basis, not a user basis? And also, How would having 10 "local" printers affect this script?
 
Ok, tested this out and it only works for user logon scripts, not computer startup scripts, which is what I want to do. I don't want to have to create 300 GPO's for default printers, I want to add 1 GPO to Computers, have them determine their name, and then set a port path and default for a printer based on the room number. Any other ideas?
 
You are approaching this off a little.

Printers are configured on a user basis. So you would need to execute the script as a user. You can THEN have the script check for the machine name and take action based on that. Use a Select Case statement similar to what I do in my login script for checking group memberships.

Soemthing like this:
Code:
Select Case strComputer
   Case "Machine1"
        code to execute
   Case "Machine2"
        code to execute
End Select


I hope you find this post helpful.

Regards,

Mark
 
Mark,
Thanks for the input. I guess if what you are telling me is 100% then what I am trying to do won't work. This is hard to explain with text. What I'm looking to accomplish with the printers, is that after the computer is imaged and renamed, I want it to set a port on a printer and set it as default for whomever logs on. As If I manually added the printer as a local port. Perhaps I can still capture the machine name and the room number and make some reg changes, not sure how I can do the default printer though. The search continues...
 
You seem to be missing the point here. You can set the default printer at login and have it go where you want. What does it matter if it happens before or during login? The result is the same.

Using the above method, any user could log in and get the correct printer for that computer location.

I hope you find this post helpful.

Regards,

Mark
 
I agrea with Mark.
As part of my user login script it determins what OU the computer belogs to and then attaches the right printers. So with one script depending on where the user logs in it determins which printers are added. I found this far better then to give people *all* the printers and now I never have to ADD network printers again. Just add them to the login script.

So yes it's a user login script BUT it's determined by the computer they login to.
 
Ok, I understand what you guys are doing and saying. I don't know your environment, but for me I work in a school district. I have hundreds of rooms, each room contains a bank of computers and a printer. Also, One computer in each room is designated as a "teacher station" which is where the printer is attached to and shared, so to do a blanket logon script just won't work for me, at least right now I don't think it will. But I do appreciate your time and input, thank you very much.
 
mcanet, I'm not trying to be harsh but either you don't understand vbscript or are just not reading what we have posted. I've given you code that would dynamically map the printers based on your naming convention. The same 9 lines of code I posted in my first post would map printers for anywhere from 1 to 999 printers based on your 3 digit room number.

I hope you find this post helpful.

Regards,

Mark
 
markdmac,
I do understand and do appreciate both your help. I just have other variables involved that I haven't disclosed to you guys. But really I do appreciate the help and the code you gave me should help me very much, Thank You for that. My last issue is the teacher computer that the printer is attached to and shared from. I will have to try and figure out a way of detecting the printer that is attached to the computer and then sharing it. I would imagine that that wouldn't be hard right?
 
I was wondering about that whole setup with the instructors station. I manage a network for school (800 kids 300 machines). And one of the first things I had to do was get rid off all the personal teacher printers (fortune in ink) and add networked shared laser printers. Which I think it what you looking to do. The big problem of sharing a printer off a computer is.. well.. what happens if you turn off the computer or it goes down? No printer.

All you would need to do it get some small print servers. Depending on the age of the printer most just need a usb (LPT are also available) adapter like the Zonet ZPS1000 1-Port 10/100 USB 1.1 Print Server for like 40$. Now you have a networked printer. I've also found that having a print server (ie windows, linux) was better then printing directly to a printer because it allows more flexabilty (printer change, ip change etc.)
Of course im making assumptions about your network.

OT: Don't you think there should be a forum for Education Related IT questions? I think most of us suffer the same issues. :: shrugs ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top