Re: Writing to a printer from a WSH script called by ASP

From: Roland Hall (nobody_at_nowhere)
Date: 10/21/04


Date: Thu, 21 Oct 2004 11:22:50 -0500


"Schadrach" wrote in message
news:1098320686.170352.208660@f14g2000cwb.googlegroups.com...
: Err, there are plenty of reasons for wanting to do this. The one that
: people giving examples like to cite is firing of shipping labels to the
: shipping & receiving dept when something is ordered on an e-commerce
: site. In my case, we have a specialized piece of hardware made to
: print plastic/metal tags, and an intranet app that already manages the
: data that need to go on them. Anyone who can access the page that
: prints the tags has already been authenticated by the system as being
: an employee whose responsibilities may include producing said tags.

Schadrach...

I took Gerry's suggestion and wrote a small example and tested it. My setup
will be a little different from yours so yours may have better results.

This is my setup:

Workstation sharing a USB printer on domain1
W2K Adv. Server running IIS on domain2

I mapped lpt1 on the server to the printer share on the workstation
I made a virtual directory [bob] on one of the server's partitions and put
my .asp file in it.
Rights: Administrators (Full), IUSR_FS1 (RX).
I created a data directory [bobdata].
Rights: Administrators(Full), IUSR_FS1 (R)
I call the .asp file which is written to copy ticket1 to lpt1, which
hopefully will send it to the printer.

My results are:
1. When calling the .asp file from the workstation, I get prompted for
credentials [anonymous users are disabled] and even though I give it admin
credentials, I get permission denied.
2. When calling the .asp file from the server [same way]
http://fs1/bob/printit.asp, it works. The line number that returns for
Permission Denied is line 22, the copy line.

Here is my code:

<%@ Language=VBScript %>
<%

Option Explicit
Response.Buffer = True

Const strPath = "d:\bobdata\"

sub goPrint(strFile)
  dim fso, strPort
  set fso = CreateObject("Scripting.FileSystemObject")
  strPort = "lpt1"
  Response.Write "Printing " & ucase(strFile) & "..."
  fso.CopyFile strPath & strFile, strPort
  set fso = nothing
  Response.Write "complete!"
end sub

goPrint "ticket1"

%>

Error:
Technical Information (for support personnel)

  a.. Error Type:
  Microsoft VBScript runtime (0x800A0046)
  Permission denied
  /bob/printit.asp, line 22

  b.. Browser Type:
  Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)

  c.. Page:
  GET /bob/printit.asp

  d.. Time:
  Thursday, October 21, 2004, 11:50:16 AM
My web server is not part of my other domain so I cannot test a system in
that domain without config changes to one of my workstations. Perhaps you
will have better results. If that doesn't work, I have one other
possibility.

-- 
Roland Hall
/* This information is distributed in the hope that it will be useful, but 
without any warranty; without even the implied warranty of merchantability 
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


Relevant Pages

  • fso security problem
    ... I have two W2000 servers and one Workstation in one domain. ... I have an ASP file with a GetFile function that run on ... Server A. The Getfile function point to a file stored on ... If I run the ASP file from IE on Server A, ...
    (microsoft.public.inetserver.iis.security)
  • Re: Re-Post - "the trust relationship between this workstation and
    ... There were no logged events in either the DC or workstation. ... DC/DNS Server - DCDiag ... Attr: subschemaSubentry ... only problem is adding a new user account on the station. ...
    (microsoft.public.windows.server.active_directory)
  • trust relationship between workstation and the primary domain fail
    ... When I am at a workstation attached to the domain and try to add a local ... Server: server1.contoso.org ... Testing LDAP servers in Domain contoso ... ... Attr: subschemaSubentry ...
    (microsoft.public.windows.server.general)
  • RE: Slow Logon related to groups
    ... Open Server Management console on SBS ... Ensure the problematic user has permission to access its home folder on ... After the problematic user logon workstation, ...
    (microsoft.public.windows.server.sbs)
  • Re: =?ISO-8859-1?Q?Can=92t_see_a_compute?= =?ISO-8859-1?Q?r_in_the_network?=
    ... Find Computer Browser ... Find Server ... Find Workstation ... CONFIG and Browser and Sharedaccess are RUNNING. ...
    (microsoft.public.windowsxp.network_web)