Results 1 to 2 of 2

Thread: Need help, should be a quick fix

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    2

    Need help, should be a quick fix

    So I created this script shown below that adds a printer as a default if you click on it. It works perfectly if the file is on a users local computer but once I put it on the webserver and go to the address using port 8080 it won't work and give me the error I created.

    What's wrong?

    thanks for your time,
    Bruce

    Code:
    <head>
    <SCRIPT LANGUAGE="VBScript">
    Function connect(printer)
       On Error Resume Next
           
           strUNCPrinter = "\\cpowst01\" & printer
           
           Set objNetwork = CreateObject("WScript.Network")
           objNetwork.AddWindowsPrinterConnection strUNCPrinter
    
           If Err <> 0 Then
         MsgBox "The selected printer " & printer & " could not be connected. Please contact the helpdesk (x. 2750) for assistance in connecting this printer", 0, "Connection Error"
           Else 
               myVar = MsgBox("You have been connected to the selected printer. Do you wish to set this as your default printer?", vbYesNo, "Connection Status")
               If myVar = 6 Then
                   objNetwork.SetDefaultPrinter strUNCPrinter
                   MsgBox printer & " is now your default printer", vbOKOnly, "Connection Status"
               Else
                   MsgBox printer & " is now connected", vbOKOnly, "Connection Status"
               End If
           End If
           Return false
    End Function
    </SCRIPT>
    </head>
    <body background="3rdFloorSouth.jpg" style="background-repeat: no-repeat; background-position:top;">
    <font size="5" color="red">
    <BR>
    <br>
    <BR>
    <BR>
    1. <button onClick="connect('wcc3sp1')">wcc3sp1</button>Black/White    <br>
    
    2. <button onClick="connect('wcc3sp2')">wcc3sp2</button>Black/White    <br>
    
    3. <button onClick="connect('wcc3sp3')">wcc3sp3</button>Black/White    <br>
    
    4. <button onClick="connect('wcc3sp4')">wcc3sp4</button>Color    <br>
    
    5. <button onClick="connect('wcc3sc6')">wcc3sc6</button>B/W OCE/Copier    <br>
    
    </body>
    </html>

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2008
    Posts
    2

    Re: Need help, should be a quick fix

    So i figured the problem is that I need to create an object for this line

    Code:
    Set objNetwork = CreateObject("WScript.Network")
    How do I create that object?? thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width