Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:31:56+00:00 2026-06-04T04:31:56+00:00

I would like to run commands in a batch file on multiple computers. For

  • 0

I would like to run commands in a batch file on multiple computers.

For example:

@echo off
ping %1
pause
exit

If this batch file were called pingme.bat, and I type pingme.bat yahoo.com, then it would ping yahoo.com. My problem is I want the batch file to accept input from a text file.

For example, pingme.bat computers.txt would read the names of computers listed in the computers.txt file, and do whatever command I specified to be done to them.

%1 accepts the input I specify when I type the batch file. Now I would like the batch file to read the lines from that input text file and use them as arguments to the command.

The lines in the text are in list form, not using commas or anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:31:57+00:00Added an answer on June 4, 2026 at 4:31 am

    One way to do so would be to place the URLS in a text file like so:

    http://www.google.com
    http://www.yahoo.com

    Then run the following batch

    for /f %%a in (%1) do (
    echo Pinging %%a...
    ping %%a
    )
    

    and run it from cmd as pingme.bat URLs.txt

    Alternatively, you may specify the text file’s name within the batch, and run it without the parameter

    for /f %%a in (URLs.txt) do (
    echo Pinging %%a...
    ping %%a
    )
    

    Here’s another approach

    This particular batch will pull from the list, and write to output.txt if the ping was successful

    @ECHO OFF
    SET output=output.txt
    IF EXIST "%output%" DEL "%output%"
    FOR /f %%a IN (URLs.txt) DO (
        CALL :ping %%a
    
    )
    GOTO :EOF
    
    :ping
    ping -n 1 %1 | find "Approximate round trip" >NUL || ECHO %1>>"%output%"
    

    Hopefully that sets you in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the problem I'm having: @ECHO OFF REM If this batch file is
I would like to run a set of python commands from a file in
I would like to run a batch (.bat containing DOS commands) that would clean
I would like to create a ruby script that I can run mysql commands
From inside a batch file, I would like to test whether I'm running with
I need to run a batch file, with a series of powercfg commands to
I have a batch file that creates a scheduled task using schtasks like this:
Here's a minimal batch file, demo.bat , to illustrate my problem: @ECHO off set
I build packages from a batch file using commands like: msbuild ..\lib\Package.dproj /target:Build /p:config=%1
I would like to run the following SQL select: SELECT ID, NUMERATOR, (SELECT m.COLUMNNAME

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.