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.Netw ork")
objWSNET.AddWindowsPrinter Connection "\\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>
thanks...
<%@LANGUAGE="VBSCRIPT"%>
<%
Dim objWSHNet
set objWSNet = CreateObject("Wscript.Netw
objWSNET.AddWindowsPrinter
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>
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
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.
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.
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?
ASKER
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.AddPrinterConne ction "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
Try this:
==========================
' Create reference to the Wscript network object
set WshNetwork=CreateObject ("Wscript.Network")
' Call the addprinterconnection method
WshNetwork.AddPrinterConne
' Attach u: to \\servername\sharename
WshNetwork.MapNetworkDrive
' 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
ASKER
Your method use the addprinterconnection instead of addwindowsprinterconnectio n. 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("WScr ipt.Networ k")
PrinterPath = "\\printserv\DefaultPrinte r"
WshNetwork.AddWindowsPrint erConnecti on 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
Set WshNetwork = WScript.CreateObject("WScr
PrinterPath = "\\printserv\DefaultPrinte
WshNetwork.AddWindowsPrint
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
ASKER
Thanks, I tried all these...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 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
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
Computer101
E-E Admin
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