Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 9th, 2006, 07:10 AM
Authorized User
Join Date: Jun 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Add Printers

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">

Dim objNetwork

Set objNetwork = CreateObject("WScript.Network")

objNetwork.AddWindowsPrinterConnection "\\AYL-DC-01\A51020D"
objNetwork.SetDefaultPrinter "\\AYL-DC-01\A51020D"
<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";

<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 id="commonMenu">
        <div class="menuHeader"><a href="/">Home</a></div>
    <div id="pageInfo">
        <h2><script type="text/javascript">document.write(document.title)</script></h2>
    <div id="content">
        <div class="contentHeader">
        <div class="contentMain">
        <div class="contentFooter">
    <div id="commonFooter">
        <div id="quickLinx">
            <p class="floatRight">&copy; 2006 Aylesford School - Sports College. All rights reserved.&nbsp;</p>

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/...

Old November 14th, 2006, 09:18 AM
Friend of Wrox
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts

Your code would set the printer on the webserver; if I browse to your website, nothing would change on my computer. I think that you are tring to set my printer up ... in which case you need to switch the code to (client-side) Javascript.

<script lanjaguage="javascript">
var objNetwork;
    objNetwork = new ActiveXObject("WScript.Network");
    objNetwork = null;


Sean Anderson
Old November 14th, 2006, 09:20 AM
Friend of Wrox
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts

The permission denied is because the webserver is trying to add the printer ... the webserver is probably setup to act as an anonymous user (IUSER_<computer>) and as such wouldn't really have permissions to do this. That's by-the-by really as in my previous reply, I think that you want to be coding on the client computer rather than the server.


Sean Anderson

Similar Threads
Thread Thread Starter Forum Replies Last Post
List the Available printers ajit Java Basics 2 May 4th, 2007 07:54 AM
How to show all available printers name? vijaykumartaduri General .NET 1 October 13th, 2006 12:03 AM
Printing and printers neilsands Java Basics 1 May 4th, 2006 08:57 AM
Deleted Printers Table Teqlump Access VBA 1 September 10th, 2004 05:50 PM
Delete Printers Table Teqlump VB Databases Basics 1 September 10th, 2004 04:45 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.