Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 9th, 2006, 06: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">

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

Reply With Quote
  #2 (permalink)  
Old November 14th, 2006, 08:18 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.AddWindowsPrinterConnection("\\AYL-DC-01\A51020D");
    objNetwork.SetDefaultPrinter("\\AYL-DC-01\A51020D");
    objNetwork = null;
</script>

Regards,

Sean Anderson
Reply With Quote
  #3 (permalink)  
Old November 14th, 2006, 08:20 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Regards,

Sean Anderson
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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



All times are GMT -4. The time now is 06:23 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.