Windows batch file to open webpage in IE and run javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Studlyami
    Recognized Expert Contributor
    • Sep 2007
    • 464

    Windows batch file to open webpage in IE and run javascript

    Hey all, I'm trying to create a simple (I think it should be simple) batch file. I want this file to open Internet Explorer 6 go to the webpage SIRIUS Satellite Radio - The Best Radio On Radio and run the javascript: launchPlayer(", ",","); Is this possible? I don't know anything about batch files and i only got to the point where i can open the webpage, but i am unable to open it in IE.

    I tried

    START "C:\Program Files\Internet Explorer\IEXPLO RE.EXE" "www.sirius.com "

    but this line opens up the webpage in firefox(my default browser).
    How do i get internet explorer to open this web page when its not my default browser?
    How do i run the javascript: launchPlayer(", ",","); ?

    any help would be appreciated.
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    I don't know about the "starting with IE" part, but instead of opening that JS, why don't you just go to this page?

    Greetings,
    Nepomuk

    Comment

    • anijos
      New Member
      • Nov 2008
      • 52

      #3
      Hi,


      If IE is your default browser create the bat file as:

      Code:
      start http://www.sirius.com
      if not(in ur case):

      Code:
      start iexplore http://www.sirius.com
      AniJos

      Comment

      • Studlyami
        Recognized Expert Contributor
        • Sep 2007
        • 464

        #4
        Nepomuk thanks for the link! i couldn't find that address so that help solves that initial problem. Also thanks anijos for your reply that line works just fine.
        Code:
        start iexplore http://www.sirius.com
        Why wouldn't my line not work?
        Code:
        START "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "www.sirius.com"
        After opening this page in IE is there a way to run a javascript command on that page (for future reference)?

        Comment

        • AmberJain
          Recognized Expert Contributor
          • Jan 2008
          • 922

          #5
          Originally posted by Studlyami
          Why wouldn't my line not work?
          Code:
          START "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "www.sirius.com"
          Well, if the there is only one command line arguments (CLA) and that too a a string to 'start' command, then that string becomes the title of the new instance of cmd that starts. And that is why the code:
          Code:
          START "C:\Program Files\Internet Explorer\IEXPLORE.EXE" "www.sirius.com"
          starts a new instance of cmd.exe with the window title as "C:\Program Files\Internet Explorer\IEXPLO RE.EXE". The parameter "www.sirius.com " is not at all looked after by 'start' command.
          Still if you would like to start iexplore.exe using the full path to iexplore, then you should instead use:
          Code:
          START C:\"Program Files"\"Internet Explorer"\IEXPLORE.EXE
          This will do what you want. Although in modern windows OSes, DOS (i.e. NT virtual DOS machine or ntvdm.exe) has LFN support with no " " for filenames/folder names which have a whitespace character but some commands such as 'start' etc. still demands user to use " " in case of directory/filenames with a white space in between. For e.g. You can change to directory [Documents and settings] without use of " " i.e.
          Code:
          cd Documents and settings
          but if you want to use the path to [Documents and settings] as a CLA to 'start' command then you should include the string [Documents and settings] between " " i.e.
          Code:
          start c:\"Documents and settings"\abcde.exe
          Originally posted by Studlyami
          After opening this page in IE is there a way to run a javascript command on that page (for future reference)?
          I dont have ideas about this....

          Hope this helps....
          AmbrNewlearner
          Last edited by AmberJain; Dec 4 '08, 09:14 AM. Reason: added something.....

          Comment

          • Studlyami
            Recognized Expert Contributor
            • Sep 2007
            • 464

            #6
            Yeah that does help. Thanks a lot for that explanation.

            Comment

            • alex51164
              New Member
              • Nov 2011
              • 1

              #7
              First, you need to go to the browser, press tools, go to internet options, and press the programs tab. You will see the Set Default Browser.

              Comment

              Working...