Hi guys,
I'm very new to the soft side of networking. I am trying to create a script that lets users select a printer from a predetermined list to add to their machine. Also, I would love to let them then select one to be the default. This is all I could come up
with and I would appreciate any help I can gather.
<SCRIPT Language="VBScript">
Sub Window_Onload
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer")
For Each objPrinter in colPrinters
strPrinter = objPrinter.Name
Set objOption = Document.createElement("OPTION")
objOption.Text = strprinter
objOption.Value = strPrinter
AvailablePrinters.Add(objOption)
Next
End Sub
Sub SetDefault
strPrinter = AvailablePrinters.Value
Set WshNetwork = CreateObject("Wscript.Network")
WshNetwork.SetDefaultPrinter strPrinter
Msgbox strprinter & " has been set as your default printer."
End Sub
</SCRIPT>
<select size="5" name="AvailablePrinters"></select><p>
<input type="button" value="Set as Default" onClick="SetDefault">