Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I print multiple html files located on web, and not on a local drive?

Something like:

Can I create a batch file? Or is there a better approach to print about 500 html documents, each only different by ?ID=.

share|improve this question

migrated from serverfault.com Mar 14 '12 at 14:23

This question came from our site for professional system and network administrators.

    
I think this question should be migrated to superuser –  m0ntassar Mar 14 '12 at 14:10
    
Which OS? Please provide any relevant details. –  jscott Mar 14 '12 at 14:13
    
Windows 7, or Windows XP –  John Mar 14 '12 at 14:17
add comment

1 Answer 1

up vote 1 down vote accepted

You can do it with Windows PowerShell (available natively on Windows 7, must be downloaded for Windows XP/Vista)

The quick and dirty script looks like this (you can paste it to a PowerShell window or save as a .ps1 file):

$ie = new-object -com InternetExplorer.Application
$ie.visible = $false
$url = "http://www.domain.com/file.html?ID="
For ($id=1; $id -le 500; $id++) {
  $ie.Navigate($url+$id.ToString())
  while ($ie.busy) {start-sleep -milliseconds 500}
  $ie.ExecWB(6,2)
}

This should work if your IDs really are sequential (from 1 to 500).

What it does:

  • Create an Internet Explorer instance (not visible)
  • Set the desired URL (minus the ID number at the end)
  • Loop throught all IDs from 1 to 500 and print them to your default printer (the $ie.ExecWB(6,2) line)
share|improve this answer
    
Looks interesting. How to run a ps1 file? I am using command "powershell -noexit test.ps1", but I get an error that ps1 file is not valid –  John Mar 15 '12 at 9:56
    
@John - try using the full path to the script file: powershell.exe -noexit &'c:\Documents and Settings\username\My Documents\test.ps1'. See this page for more information –  Siim K Mar 15 '12 at 16:14
    
Actually I have visited that particular page, but I end up with this error. The term 'c:\print.ps1' is not recognized as the name of a cmdlet, function, sc ript file, or operable program. Check the spelling of the name, or if a path wa s included, verify that the path is correct and try again. At line:1 char:13 + c:\print.ps1 <<<< + CategoryInfo : ObjectNotFound: (c:\print.ps1:String) [], Comman dNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Windows\System32\WindowsPowerShell\v1.0> –  John Mar 15 '12 at 16:24
    
Furthermore I get the error, unable to access to the registry key when i execute Set-ExecutionPolicy RemoteSigned. –  John Mar 15 '12 at 16:59
    
Used page to set Execution Policy. –  John Mar 15 '12 at 17:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.