locked
How to code batchfile? RRS feed

  • Question

  • On following batchfile coding, I would like to know on how to code a batchfile, so it would open a URL from text file.

    Within ABC.txt, it contains http://www.google.com

    Does anyone have any suggestions?
    Thanks in advance for any suggestions

    --------------------------------------------------------------------------------------------------------------------

    Not working

    @echo off
    start /b /max "IE" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" (Get-Content 'D:\ABC.txt')

    --------------------------------------------------------------------------------------------------------------------

    Working

    @echo off
    start /b /max "IE" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" "http://www.google.com"




    Thanks in advance for any suggestions



    • Edited by oemMicrosoft Thursday, December 18, 2014 2:48 AM
    Thursday, December 18, 2014 2:40 AM

Answers

  • A shell script (batch file) does not use get-content. That is PowerShell.

    PowerShell does not use "@echo off" and doesn't use the "start /b /max" command.

    You can't combine shell script (batch file) code and PowerShell code in the same file. That will not work.

    I recommend using PowerShell. You can use start-process.


    start-process "$Env:ProgramFiles(x86)\Internet Explorer\iexplore.exe" (get-content "D:\abc.txt") -windowstyle maximized


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by oemMicrosoft Thursday, December 18, 2014 3:04 AM
    Thursday, December 18, 2014 2:49 AM

All replies

  • A shell script (batch file) does not use get-content. That is PowerShell.

    PowerShell does not use "@echo off" and doesn't use the "start /b /max" command.

    You can't combine shell script (batch file) code and PowerShell code in the same file. That will not work.

    I recommend using PowerShell. You can use start-process.


    start-process "$Env:ProgramFiles(x86)\Internet Explorer\iexplore.exe" (get-content "D:\abc.txt") -windowstyle maximized


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by oemMicrosoft Thursday, December 18, 2014 3:04 AM
    Thursday, December 18, 2014 2:49 AM
  • Thank you very much for suggestions :>

    Thanks in advance for any suggestions

    Thursday, December 18, 2014 3:05 AM