Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for a way to send print job to printer, no user interaction

Status
Not open for further replies.

joemadera

Technical User
Jun 27, 2006
14
US
Hello,

I have this post in both VBSCRIPT and now here. Hoping someone will have an idea.

I have an internal web page for work requests. The way it works is that the user opens the page, fills out the form, and clicks submit. I have some script that when they click submit I record the current default printer, add a new one, set it as default and launch window.print...this all works fine, but what I want to have, is that when they click Submit, they are not prompted with the windows print dialog box, it just sends to the default printer. I saw something a few months ago about an object that would do something of this sort, but I can not for the life of me find it again..

Any help greatly appreciated

Thanks
 
I have an update.

I started using wbcontrol.execwb, it works great, just not in my data access page.

I will post there now to see if anyone has experience using this object.

If anyone here has any experience using this I would like to hear from you.

Thanks

 
I spent a whole week researching this very same question. It looks like it was possible to print without prompt in Internet Explorer 5.5 or earlier, but Microsoft has blocked this function's access in their latest browsers.

Here is the function that "used to" work in IE 5.5 and lower:

Code:
function PrintWindow(){ 
if (navigator.appName == "Microsoft Internet Explorer") { 
     var PrintCommand = '< O B J E C T ID="PrintCommandObject" WIDTH=0 HEIGHT=0 ';
PrintCommand += 'CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></O B J E C T>';
     document.body.insertAdjacentHTML('beforeEnd', PrintCommand); 
     PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = ""; } 
else { window.print();} }

DigiOz Multimedia
 
I found an easy way to do this awhile back.

I can share this info, it works fine with ie6 and 7.

I used an asp page to do this and some vbscript to add a new network printer to the users page, set it as default, then wbcontrol to send it to the printer with no interaction on the client side what so ever. WBControl only sends to the default, so you have to set it up ahead of time.

But now I have a new question:

Here is the code..I suppose you could do this another way, but here is how I did it. This the basics of all you need.

<head>



<object ID="IE" WIDTH="0" HEIGHT="0"
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">

'defined object for automatic printing



</object>

</head>



<script LANGUAGE=vbscript event=onload for=window>

Public RegKey, HivePath


Dim WshShell

Set WSHShell = CreateObject("WScript.Shell")


HivePath = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"


'recording current default printer for later use


Regkey = WshShell.RegRead(HivePath)



'going to add new printer and change to default printer


Set WshNetwork = CreateObject("WScript.Network")



PrinterPath = "\\ServerName\Maint"
PrinterDriver = "HP LaserJet 6P"
WshNetwork.AddWindowsPrinterConnection PrinterPath, PrinterDriver
WshNetwork.SetDefaultPrinter "\\ServerName\Maint"

</script>

<Script>

IE.execwb 6,2

msgbox "Your Request Has Been Submitted"

</SCRIPT>



<script language=vbscript event=onunload for=window>

'***CHANGING BACK TO OLD PRINTER

Dim WshShell

Set WSHShell = CreateObject("WScript.Shell")

PrinterPath = "\\Servername\Maint"
PrinterDriver = "HP LaserJet 4050 Series PS"
WshNetwork.RemovePrinterConnection PrinterPath, PrinterDriver

WshShell.RegWrite HivePath ,RegKey, "REG_SZ"

</SCRIPT>

</body>

</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top