Automation

 View Only
  • 1.  how to open locally created file with IE?

    Posted Mar 10, 2009 10:48 PM

    I have a script that creates an html file on the fly, and I want to be able to open it with IE upon completion.

    I define the output file variable as: $out = "report.htm"

    I want to specify a relative path on purpose as I will run this from a jump drive, so the file should be created next to my script on the jump drive.

    And at the end of the script I use:

    & "$env:programfiles\Internet Explorer\iexplore.exe" $out

    The file gets created, but IE goes looking for a URL with the expanded name of my $out variable and fails.

    If I hard code the value of $out in my script to be "C:\report.htm" then everything works.

    The issue is, I never know the drive letter the system will assign my jump drive, and I do not want to write to the C drive, so want to try to use relative path names. Is there a way to accomplish this?

    Thanks!



  • 2.  RE: how to open locally created file with IE?

    Posted Mar 11, 2009 01:32 AM

    Invoke-Item is your friend.






    [vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator

    Author of the upcoming book: Managing VMware Infrastructure with PowerShell

    Co-Host, PowerScripting Podcast (http://powerscripting.net)

    Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org



  • 3.  RE: how to open locally created file with IE?

    Posted Mar 11, 2009 01:54 PM

    Than you, that did it!