View Full Version : Convert vbs code to jscript

02-25-2003, 07:40 PM
I wanted to convert this visual basic script to JavaScript to embed in a web page.

I can call the vbs file from a link in the browser but that forces a diolog box that asks the user if they want to download or open the file.

The script is designed to run from a web page for w2k users to install network printers instead of using the standard windows add printer wizard.

I have not been able to find compatible code for the network printer objects.

***** sample code *********

'*** Set printer path
call SetPrinter("\\printserver\printername")

'*** This subroutine installs and sets the default printer
Sub SetPrinter(ByVal PrinterPath)
DIM WshNetwork
Set WshNetwork = CreateObject("WScript.Network")

End Sub

******* end of code **********

02-25-2003, 07:58 PM
i dont think JS can install printers...

06-14-2003, 08:40 AM
<script language="JScript">
function SetPrinter(PrinterPath)
var WshNetwork=new ActiveXObject("WScript.Network");

<a href="#" onclick="SetPrinter('\\path\printerName');">Set Printer</a>

It will bring up an ActiveX alert in standard Internet Explorer. If you make this into an HTA, you won't get the error.