Creating a bat file that runs a certain command on cmd

48,543

Solution 1

Another way of doing this (potentially a lot easier for you) would be to create a shortcut:

  1. Right Click in windows explorer and hover over "New"
  2. Select "Shortcut"
  3. A dialogue will pop-up. Enter the command you wish to utilize: ping 216.52.241.254 -t
  4. Click Next and name the file.
  5. Now whenever you open the shortcut, it will execute the command.

The advantage of this method over the other is its simpler and allows you to pin it to the Starmenu or Taskbar.

Mona.

Solution 2

It spammed it over and over because you called the batch file ping so it was launching itself.

Solution 3

Very simple:

@echo off
ping 216.52.241.254 -t
Echo.
pause
  1. Open Notepad
  2. Copy and paste this in.
  3. Save as a .bat file, ensuring that you select "all files" option
  4. Run the batch file any time you want to check your ping.

Done!

Solution 4

type the following:

cd\ 
ping -t 216.52.241.254 

Solution 5

You must have keep the file name as 'ping.bat'. Rename it to something else and it will definitely work. ex : ping1.bat, something.bat etc., anything else but ping.

Share:
48,543
Admin
Author by

Admin

Updated on July 05, 2022

Comments

  • Admin
    Admin almost 2 years

    So normally I can type this into the cmd window ping 216.52.241.254 -t and it tells me my ping to a certain server. How can I create a .bat file that automatically opens the cmd window and types it in so that I don't have to write it out every single time. I tried just putting in ping 216.52.241.254 -t and it just spams it over and over again.