简体   繁体   中英

Creating a bat file that runs a certain command on cmd

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.

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.

它一遍又一遍地发送垃圾邮件,因为你调用了批处理文件ping所以它自己启动了。

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!

type the following:

cd\ 
ping -t 216.52.241.254 

It spams it again and again because you used -t which "Pings the specified host until stopped." if you lose the -t it won't do that. Type Ping /? to look through all the options available when using ping and select what is appropriate for what you want it to do.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM