Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Help with a script

  • 24-01-2007 11:40am
    #1
    Closed Accounts Posts: 3,413 ✭✭✭


    Hi all,

    Through my very limited knowledge of VB scripting I've thrown together (from microsoft) a script that will install and map a printer with one click -


    Option Explicit
    Dim netPrinter, UNCpath
    UNCpath = "printer name"
    Set netPrinter = CreateObject("WScript.Network")
    netPrinter.AddWindowsPrinterConnection UNCpath
    netPrinter.SetDefaultPrinter UNCpath

    WScript.Echo "Your printer is mapped from : " & UNCpath
    WScript.Quit

    And so on!

    I am in the middle of putting together a mini web site, where i can point people in my company to locate the printers.

    Any ideas how i could do the above on a web-site, I have no knowledge of web-site creation etc.

    Any help appreciated.


Comments

  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    You'll need to add in client-side VBScript on the page to do it.

    Results here can vary. It will only work in IE, and depending on your domain/network/security setup, it may work for some users, or all users or no users.

    I had some success with the below though
    [html]<script language="vbscript" type="text/vbscript">
    Function MapPrinter(UNCPath)
    On Error Resume Next
    Dim netPrinter
    Set netPrinter = CreateObject("WScript.Network")
    netPrinter.AddWindowsPrinterConnection UNCpath
    If Err <> 0 Then
    msgbox "Error mapping printer" & vbCRLF & vbCRLF & "Printer Name: " & UNCPath
    Else
    netPrinter.SetDefaultPrinter UNCpath
    msgbox "Success!" & vbCRLF & vbCRLF & "Your printer is mapped from : " & UNCpath
    End If
    End Function
    </script>

    <script for="myLink" event="onclick" language="vbscript">
    MapPrinter("\\myServer\myPrinter")
    </script>


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <a href="#" id="myLink" onClick="CatchMe">Click</a>
    </body>
    </html>
    [/html]


  • Closed Accounts Posts: 3,413 ✭✭✭HashSlinging


    Thanks Seamus,

    Is this also part of the script or was this copied in error.


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd"&gt;
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <a href="#" id="myLink" onClick="CatchMe">Click</a>
    </body>
    </html>


  • Registered Users, Registered Users 2 Posts: 2,781 ✭✭✭amen


    could you add it to the users login script?
    since you appear to be running Windows why not set up the printer in a user policy and apply to all users?
    Have you talked to your network admin?


  • Closed Accounts Posts: 3,413 ✭✭✭HashSlinging


    there are over 600 people working here and nearly as many printers, so that would be a lot of admin, rather just point them to the site (which will be on the intranet) and forget about it.

    I am the network admin! I currently have the printers setup in lotus notes with a short cut to the above vbs script, once the person clicks the printer it maps and sets as default, but that still involves sending an email out, which I want to stop.


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Thanks Seamus,

    Is this also part of the script or was this copied in error.
    That's just the example HTML. If you want to put it on the Intranet, you're going to need HTML :)


  • Advertisement
Advertisement