In one of my desktop apps, I am generating an HTML file, and then opening it in Explorer and immediately firing off a window.print() command, to allow my users to print the generated document. I also fire a window.close() command in the onafterprint event handler, so that the generated document will close itself as soon as it's done with the print dialog, thereby saving my users the extra click to close it (trying to, anyway...). I've run into two separate snags, though:

#1) The gold bar appears on top in IE7, saying: To help protect your security, Internet Explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer.

The only reason I'm opening Explorer is to take advantage of its rendering engine to display and print the simple HTML I generated, so IE is not my main focus here, it's the desktop app that generates the HTML and calls IE that's really in charge.

Because my users are running this application in the first place, I can assume that I have the ability to add or modify registry keys. So is there any way (any reg keys I can add, for instance?) to specifically tell IE that a local file at a given location (e.g. "C:\print.html") will always be safe to run JavaScript? (without prompts)

#2) IE7 no longer lets the last remaining window close itself--not without being met with this prompt, anyway: The webpage you are vieiwing is trying to close the window. Do you want to close this window? In previous versions, this could be accomplished by setting window.opener to something non-empty, and then closing the window. IE7 now prevents this. So... has anyone found a workaround to this yet? Any way to close the window without the annoying prompt?

My only other alternative is to use some sort of HTML printing utility, such as HTMLPrint--except I have yet to find anything with any sort of reasonable price for use with a commercial application. So I figured I'd just use something that all my users already have: IE. Except it's not the ideal solution with all the extra clicking involved. I could just tell them to hit "File - Print" manually and skip the JS altogether, but that too isn't very ideal.