Install a remote printer via a Hyperlink in HTML

Ever tried to install a printer by just giving users a link?  Well here is a small snippet of one way to do this.   Please note that since you are interacting with the OS (outside the browser) that you may receive security warnings.   This has been tested on Vista SP1 x86 32 bit with IE7.

Code

<html>
<head>
<script type="text/vbscript">
function AddP(pName)
msgbox "Start"
Set WshNetwork = CreateObject("Wscript.Network")
WshNetwork.AddWindowsPrinterConnection pName
msgbox "Finished"
end function
</script>
</head>
<body>
<a href='#' language="vbscript" onclick="AddP('\\Home-PC\HP Photosmart 3300 series')">Add printer</a>
</body>
</html>

 Please note that above the a href should be ="#" not single quotes.

Comments

  • Anonymous
    February 13, 2009
    PingBack from http://www.clickandsolve.com/?p=7606

  • Anonymous
    July 30, 2009
    Every piece of data necessary to succeed, from basic tools and commands to vocabulary and layout creation, is packed into the nice post.

  • Anonymous
    October 07, 2014
    Hi, Script not working after hosting IIS, but working when open from local Please advise if any other option available Regards, Fasil