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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AddWindowsPrinterConnection

Status
Not open for further replies.

SparkysHouse

Technical User
Joined
Nov 5, 2002
Messages
2
Location
US
The following code works perfectly when run from a .vbs file. How can I utilize this code from a web page form button? Currently, the code errors on the first line.


Set WshNetwork = WScript.CreateObject("WScript.Network")

Code:
PrinterPath = "\\ServerName\PrinterName"
WshNetwork.AddWindowsPrinterConnection PrinterPath
WshNetwork.SetDefaultPrinter "\\ServerName\PrinterName"

Thanks in advance.

[pc3]Mark
 
I may be wrong here but I believe you need to drop the Wscript as shown below,

Sorry don't have a network to test it against.

Set WshNetwork = CreateObject("WScript.Network")
Regards
Steve Friday
 
Steve,

Thanks for the quick reply. The error message now is... "Error: ActiveX component can't create object: 'WScript.Network'".

Here is the implementation...I'm open for any suggestions.

Code:
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Function Button1_OnClick()

Set WshNetwork = CreateObject(&quot;WScript.Network&quot;)
Code:
  PrinterPath = &quot;\\ServerName\PrinterName&quot;
  WshNetwork.AddWindowsPrinterConnection PrinterPath
  WshNetwork.SetDefaultPrinter &quot;\\ServerName\PrinterName&quot;
End Function
-->
</SCRIPT>
Code:
<FORM NAME=&quot;Form1&quot;>
  <INPUT TYPE=&quot;Button&quot; NAME=&quot;Button1&quot; VALUE=&quot;Install Printer&quot;>
</FORM>

Thanks in advance.

[pc3]Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top