1

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=.

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

1 Answer 1

3

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)
5
  • 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, 2012 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, 2012 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, 2012 at 16:24
  • Furthermore I get the error, unable to access to the registry key when i execute Set-ExecutionPolicy RemoteSigned.
    – John
    Mar 15, 2012 at 16:59
  • Used page to set Execution Policy.
    – John
    Mar 15, 2012 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .