set wshNetwork = CreateObject ("WScript.Network")
'deletes all network printers
Set clPrinters = WshNetwork.EnumPrinterConnections
On Error Resume Next
For i = 0 to clPrinters.Count - 1 Step 2
wshNetwork.RemovePrinterConnection clPrinters.Item(i+1), true
Next
On Error Goto 0
'maps new printers.
wshNetwork.AddWindowsPrinterConnection "\\mail\HP 4100 - Clinical - Clare"
wshNetwork.AddWindowsPrinterConnection "\\mail\HP 4000 - Admissions"
wshNetwork.AddWindowsPrinterConnection "\\medical\HP LaserJet 4000 -
Medical"
wshNetwork.AddWindowsPrinterConnection "\\mail\HP 4000 - Front Desk"
wshNetwork.AddWindowsPrinterConnection "\\mail\HP 4000 - Business Office"
wshNetwork.AddWindowsPrinterConnection "\\mail\HP 4100 - Clinical - HRC"
wshNetwork.AddWindowsPrinterConnection "\\mail\HP 4100 - Business Office"
wshNetwork.AddWindowsPrinterConnection "\\victoria\HP 4500"
wshNetwork.SetDefaultPrinter "\\mail\HP 4000 - Business Office"
Obviously I would like instead of this last statement, to have a message box
saying to choose a default printer and the choose be scripted.
----------8<---------------------
Option Explicit
Dim aOpt(7)
aOpt(0) = "\\mail\HP 4100 - Clinical - Clare"
aOpt(1) = "\\mail\HP 4000 - Admissions"
aOpt(2) = "\\medical\HP LaserJet 4000 - Medical"
aOpt(3) = "\\mail\HP 4000 - Front Desk"
aOpt(4) = "\\mail\HP 4000 - Business Office"
aOpt(5) = "\\mail\HP 4100 - Clinical - HRC"
aOpt(6) = "\\mail\HP 4100 - Business Office"
aOpt(7) = "\\victoria\HP 4500"
wsh.echo "You selected:", SelectBox("Select a default printer", aOpt)
Function SelectBox(sTitle, aOptions)
Dim oIE, s, item
set oIE = CreateObject("InternetExplorer.Application")
With oIE
.ToolBar = False : .RegisterAsDropTarget = False
.StatusBar = False : .Navigate("about:blank")
While .Busy : WScript.Sleep 100 : Wend
With .document
With .ParentWindow
if Instr(.navigator.appVersion, "MSIE 6") = 0 Then
oIE.FullScreen = True
End if
.resizeto 400,150
.moveto .screen.width/2-200, .screen.height/2-50
End With ' ParentWindow
s = "<html><head><title>" & sTitle & " " & String(80, ".") _
& "</title></head><script language=vbs>bWait=true</script>" _
& "<body bgColor=Silver><center><b>" & sTitle & "<b><p>" _
& "<select id=entries size=1 style='width:250px'>" _
& " <option selected>" & sTitle & "</option>"
For each item in aOptions
s = s & " <option>" & item & "</option>"
Next
s = s & " </select><p>" _
& "<button id=but0 onclick='bWait=false'>OK</button>" _
& "</center></body></html>"
.WriteLn(s)
With .body
.scroll="no"
.style.borderStyle = "outset"
.style.borderWidth = "3px"
End With ' Body
.all.entries.focus
oIE.Visible = True
On Error Resume Next
While .ParentWindow.bWait
WScript.Sleep 100
if oIE.Visible Then SelectBox = "Aborted"
if Err Then Exit Function
Wend ' Wait
On Error Goto 0
With .ParentWindow.entries
SelectBox = .options(.selectedIndex).text
End With
End With ' document
.Visible = False
End With ' IE
End Function
----------8<---------------------
Tom Lavedas
===========
"Robert Cohen" <rco...@bbhtx.org> wrote in message news:<ux#4ap4yCHA.2736@TK2MSFTNGP09>...
> First off, I want to thank everyone in this newgroup. You all really helped
> me script removing my network printer connections so that I could add our
> new printer connections and then define the default printer. I have the
> script below that works great. The question is, how do I take the next
> step? Right now, for this to work, I have 8 scripts, one for each printer
> on my server. I have a link on my intranet page for each so that they pick
> their default printer and run the appropriate vbs. However, what ideally I
> would like is after I do the "AddWindowsPrinterConnect", that I script a box
> that comes up and says something like, "What would you like set as your
> default printer and have a list of the 8 printers. The person would either
> click on it or choice a number corresponding to that printer. The script
> would take that user imput and install their choice as the default printer.
> I have read how to do If...Then statements in my script and I have read how
> to make a message box with user input. The question is how to take the user
> imput and put it into the If...Then statement. I assume that is how I would
> want to go.
<snip>