Click to See Complete Forum and Search --> : Add Printers


ldoodle
11-09-2006, 05:19 AM
Hi there,

I have the following code, which I would like to use to be able to install printers via a web page.

<%@ Language = VBSCRIPT %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


<html><%
Dim objNetwork

Set objNetwork = CreateObject("WScript.Network")

objNetwork.AddWindowsPrinterConnection "\\AYL-DC-01\A51020D"
objNetwork.SetDefaultPrinter "\\AYL-DC-01\A51020D"
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset='utf-8'" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="KEYWORDS" content="Aylesford; School; Sports; College; Specialist; Microsoft; Cisco; Academy; ECDL; Community;" />
<meta name="DESCRIPTION" content="The entry page to Aylesford School - Sports College's Web site." />
<meta name="CATEGORY" content="home page" />
<title>Add Printer(s)</title>
<style type="text/css" media="all">
@import "http://ayl-web-01:8081/includes/aylesford.css";
</style>
</head>
<body>

<div id="wrapper">
<div id="commonHeader">
<h1>Aylesford School - Sports College&nbsp;<img src="http://ayl-web-01:8081/images/badge.gif" alt="Aylesford School - Sports College Badge " /></h1>
</div>
<div id="commonMenu">
<div class="menuHeader"><a href="/">Home</a></div>
</div>
<div id="pageInfo">
<h2><script type="text/javascript">document.write(document.title)</script></h2>
</div>
<div id="content">
<div class="contentHeader">
</div>
<div class="contentMain">
</div>
<div class="contentFooter">
</div>
</div>
<div id="commonFooter">
<div id="quickLinx">
<p class="floatRight">&copy; 2006 Aylesford School - Sports College. All rights reserved.&nbsp;</p>
</div>
</div>
</div>

</body></html>


But i'm getting the following error message

Microsoft VBScript runtime error '800a0046'

Permission denied

/code/add_printers.asp, line 9


I am a Domain Admin as well!!?!?!

Thanks for any help/...

so_is_this
11-09-2006, 10:54 AM
In your case, this statement executes on the web server -- not on the local client:

objNetwork.AddWindowsPrinterConnection "\\AYL-DC-01\A51020D"

I believe your page is getting that message because it is not signed onto the network at that point. Thus, the network does not know that you are an administrator. If you're talking about an intranet, and you want that statement to execute on the local client, then you must use client-side scripting (IE) to execute that command.