Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Maryland
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert vbs code to jscript

    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")
    wscript.quit

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

    End Sub

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

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i dont think JS can install printers...

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script language="JScript">
    <!--
    function SetPrinter(PrinterPath)
    {
    	var WshNetwork=new ActiveXObject("WScript.Network");
    	WshNetwork.AddWindowsPrinterConnection(PrinterPath);
    }
    //-->
    </script>
    
    <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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •