@danlewis3 - there's nothing wrong with your script but this kind of thing has a tendency to grow (new rooms are added with printers etc) so my (personal!) preference is to do this kind of thing with a select statement:
Code:
select case room
case "room7"
PrinterPath1 = printserver & "\suite7biz190f"
PrinterPath2 = printserver & "\KONICA COLOUR PULL"
case "Design04"
PrinterPath1 = printserver & "\mfdkmc253design"
case else
printerpath1 = printserver & "\mainprinter"
end select
if printerpath1<>"" then
Wshnetwork.addwindowsprinterconnection Printerpath1
end if
if printerpath2<>"" then
Wshnetwork.addwindowsprinterconnection Printerpath1
end if
I just find it easier to read multiple case statements than lots of if/elseif.
The other thing I've done is move the actual addprinter bit to the end - it saves typing (making errors less likely) but also means that you can see more of the script on screen which just makes it easier to see what's going on.
I've also put in a "case else" - this deals with any room that doesn't have a specific printer. You might want this to print to some central printer (library??) or you could even have a dummy printer set up (some software won't do print preview without a print driver; like this you can have a printer driver everywhere even if there's no physical printer available)
I've left out the printer driver bit - I can't remember ever using it and looking at this MSDN page suggests that it's only needed for Windows 9x clients.
Finally (and I think this has been mentioned before) if you name your machines based on the room they're in then you can just use that instead of having to set a registry key. This is easy if your room names are all the same format (H215, B319 etc) but less easy when the rooms are all different lengths! What you could do is have names like room7_01, room7_02, design04_01 etc. This code will then get the room:
Code:
set oNet=wscript.network
sComputer=oNet.Computername
iUnderscorePos=instr(sComputer,"_")
if iUnderscorePos<>0 then
sRoom=left(sComputer,iUnderscorePos-1)
end if
If the computer name doesn't have an underscore then the script won't get a room name and the printer will be set using the "case else" bit above.
Hope this of use to someone - when you're writing scripts there are always different ways to do things; none is necessarily right or wrong but they might be better or worse for your particular setup!