When I run the script the msgbox returned the corrected printer name but the script error out saying the printer name is invaild.
I think the problem is objButton.Value it is not a string, but how can I convert it to be useful string?
Thank you,
Chi
here is my script.
<html>
<head>
<title>Connect Printer Helper</title>
<HTA:APPLICATION
ID="objTest"
APPLICATIONNAME="Add Printer"
SCROLL="yes"
SINGLEINSTANCE="yes"
>
</head>
<SCRIPT LANGUAGE="VBScript">
Sub AddSub
For Each objButton in RadioOption
If objButton.Checked Then
Msgbox "You selected " & objButton.Value
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection Chr(34) & objButton.Value & Chr(34)
WshNetwork.SetDefaultPrinter Chr(34) & objButton.Value & Chr(34)
End If
Next
End Sub
</SCRIPT>
<body>
<input type="radio" name="RadioOption" value="\\printserver\hp1300">Building 12<BR>
<input type="radio" name="RadioOption" value="\\printserver\hp4200">Admin Office<BR>
<input type="radio" name="RadioOption" value="\\printserver\hp4000">It Dept<P>
<input id=runbutton class="button" type="button" value="Add Printer" name="run_button" onClick="AddSub">
</body>
</html>
I think the problem is objButton.Value it is not a string, but how can I convert it to be useful string?
Thank you,
Chi
here is my script.
<html>
<head>
<title>Connect Printer Helper</title>
<HTA:APPLICATION
ID="objTest"
APPLICATIONNAME="Add Printer"
SCROLL="yes"
SINGLEINSTANCE="yes"
>
</head>
<SCRIPT LANGUAGE="VBScript">
Sub AddSub
For Each objButton in RadioOption
If objButton.Checked Then
Msgbox "You selected " & objButton.Value
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.AddWindowsPrinterConnection Chr(34) & objButton.Value & Chr(34)
WshNetwork.SetDefaultPrinter Chr(34) & objButton.Value & Chr(34)
End If
Next
End Sub
</SCRIPT>
<body>
<input type="radio" name="RadioOption" value="\\printserver\hp1300">Building 12<BR>
<input type="radio" name="RadioOption" value="\\printserver\hp4200">Admin Office<BR>
<input type="radio" name="RadioOption" value="\\printserver\hp4000">It Dept<P>
<input id=runbutton class="button" type="button" value="Add Printer" name="run_button" onClick="AddSub">
</body>
</html>