Link to home
Start Free TrialLog in
Avatar of vill_left
vill_left

asked on

asp and windows host script

I am trying to use WHS in asp to connect to a printer by clicking a submit button in a form. Clicking the submit button will trigger the asp code which is listed below. But it doesn't not work... what's wrong ?  
thanks...


<%@LANGUAGE="VBSCRIPT"%>
<%
Dim objWSHNet

set objWSNet = CreateObject("Wscript.Network")
objWSNET.AddWindowsPrinterConnection "\\ENV-PRINT\printer"
set objWSNet = Nothing

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Intalling...
</body>
</html>
Avatar of apollois
apollois

Do you want to print from the client's machine, or from the web server?

If you want to print from the client, you can use javascript.  Here's a print button:

<input type="image"  border="0"
       src="Printer.gif" name="btnPrint"
           onclick ="javascript:printWindow();"
         title="Print" align="middle">

This uses an image button, but you can easily adapt it for a text button
Your WSH printerconnection code looks OK.  What is not working?

Here is an article on using MS Access on the Web Server to print a report.  Perhaps it will give you some ideas:
http://www.4guysfromrolla.com/webtech/042600-1.shtml
Make sure you can meet all the conditions or there's no chance at all...from the article referenced above:

Change 3 settings on the server

Have MS Access on your server

Download SnapShot Viewer from Microsoft (http://support.microsoft.com/support/kb/articles/Q175/2/74.ASP) (SnapShot Viewer is an Application that allows you to view Access Reports without having Access installed on your machine. We will be using it as an ActiveX plug-in for the browser)

Permissions on the database will need to be set so that the iusr_MachineName account can access it.

Avatar of vill_left

ASKER

The objective of the script is to be able to add a printer in a user's pc, not to print.
Windows 2000 Active Directory and HP have web-based software that will allow the user to select and connect to a printer.  Is this what you want?
The objective is to develop a custom interface to connect/disconnect to network printers using WHS scripting. MSDN published an article how to do that in 1999 with ASP and WHS using the addprinterconnection (for winddow 98 systems). I couldn't make it work for win2k  with addwindowsprinter connection(see my script above). I have an existing  software in place that was developed in VB using WHS and it works great. This time I am trying to create a web based interface and that's why I am trying to find a way to work with ASP and WHS.
vill,

Try this:

===========================================
' Create reference to the Wscript network object
set WshNetwork=CreateObject ("Wscript.Network")

' Call the addprinterconnection method
WshNetwork.AddPrinterConnection "lpt1",

' Attach u: to \\servername\sharename
WshNetwork.MapNetworkDrive "u:", "\\servername\sharename"

' Tell the user we're all done
WScript.Echo "you are now connected to the network printer and file share"
==============================================

For more info, see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/html/scripting061499.asp

Best Regards,
Jim
Your method use the addprinterconnection instead of addwindowsprinterconnection. You must use the latter for win2k system. You connect the printer to lpt1. This is no going to work because users may wish to install numerous printers to their workstation.
Based on the MS KB, it looks like to that you have the right syntax. Here's an example from MSDN:

Set WshNetwork = WScript.CreateObject("WScript.Network")
PrinterPath = "\\printserv\DefaultPrinter"
WshNetwork.AddWindowsPrinterConnection PrinterPath


If you're using this approach, and it's not working, then check the following:
1.  Double-check the full path and name of your printer.
2.  Download and reinstall the latest version of WSH on the machine where you're trying to connect to the printer.
3.  Apply the latest Service Pack to this machine.
4.  Apply the latest "Windows Update" to this machine.

Best Regards,
Jim
Thanks, I tried all these...
ASKER CERTIFIED SOLUTION
Avatar of apollois
apollois

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
vill_left,

It has been over a month since we heard from you.  Please take action in a timely manner to close this question.  

If you used an answer proposed by one of the experts, please select his/her comments as an answer.  If you solved the problem yourself, please so state, post your solution, and ask Community Service (https://www.experts-exchange.com/Community_Support/) to refund your points.

Best Regards,
apollois
It appears that this question has been abandoned. I will make a recommendation to the EE Moderators on its resolution in one week. I appreciate any comments that would help me to make a recommendation.

In the absence of responses, I will recommend the following:
[ACCEPT apollois LAST COMMENT AS ANSWER]

Silence = You agree with recommendation or don't care.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

apollois
EE Cleanup Volunteer
Comment from expert acepted as answer

Computer101
E-E Admin