Hey,
I've been trying to get the code shown below to work on NT, and it's driving me nuts. It works flawlessly on Win2k, but not on NT 4.0. The GetActiveObject does not seem to return anything, even when several copies of IE may be running. I've searched thru the ActiveState mailing lists, etc, but I can't find any solution or workaround for the problem. Any ideas?
Thanks,
chinman
#!/usr/bin/perl -w
use strict;
my $file = 'C:\temp\index.html';
display_browser("$file");
##subroutine that supposedly displays a file in IE browser window
sub display_browser {
my $file = shift;
## convert backslashes to forward slashes in the file path
$file =~ s!\\!/!g;
if ( $^O eq "MSWin32" and "$file" and -e "$file" ) {
use Win32::OLE;
## test to see if internet explorer is already running
my $ie = Win32::OLE->GetActiveObject('InternetExplorer.Applica
+tion');
## if ie is not running, launch it, yeah right!
unless ( defined $ie ) {
$ie = new Win32::OLE( 'InternetExplorer.Application', '' )
+ or die "Yikes, can't launch Internet Explorer: $!";
}
## if we were successful in launching, make visible and naviga
+te to the proper URL
if ( defined $ie ) {
$ie->{Visible} = 1;
$ie->Navigate("$file");
}
}
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.