2

I am trying to make a shortcut that will run the following command with the following switches. The window closes before the command can run long enough. I want to know where to put the /k in the target box of the shortcut to keep the windows from closing. (I think it is /k but maybe its something else).

ping XXX.XXX.XXX.XXX -t -l 25565

My target field looks like this:

"C:\Windows\System32\PING.EXE" /k 10.98.56.1 -t -I 25565

But I don't know where the /k is supposed to go (if it is /k). can someone rewrite this with the correct syntax for me?

1
  • Note: -I is not a valid option for Ping in Windows, and Ping's -i (which is valid, it's TTL) only accepts a maximum value of 255. Commented Jan 27, 2016 at 15:59

2 Answers 2

2

The /k parameter needs to be passed to the terminal process (cmd.exe). So, your shortcut should look like this:

%COMSPEC% /k C:\Windows\System32\PING.EXE XXX.XXX.XXX.XXX -t -I 25565

Note: %COMSPEC% will resolve to cmd.exe

1
  • To be pedantic it is %ComSpec% ;)
    – DavidPostill
    Commented Jan 27, 2016 at 17:09
1

The /k argument you mentioned is for cmd.exe, not ping. So you have to call:

C:\Windows\System32\cmd.exe /k "c:\windows\system32\ping.exe" -t -I 255 192.168.1.1

The -t argument specifies that you'll ping until cancelled, and the -I parameter specifies a TTL (Time-To-Live). The maximum value of this field is 255 per TCP specification.

Before I realized the /k argument was for cmd.exe, I wrote this answer out using batch files. It might be informative and it's just another way to get the job done, so I'll leave that in case it's worthwhile.


Batch file example 1:

@ECHO OFF
ping -t -I 255 %1
pause
exit

Then you could call that batch file with the shortcut:

"c:\folder\batchfile.bat" 192.168.1.1

Of course you'd substitute the drive, folder, batch file name, and IP address.

You could also batch a series of pings using a structure like this:

@echo off
:loop
cls
ping -n 10 -I 255 %1
timeout 5
goto :loop

Which uses the -n argument to ping 10 times, then does a timeout for 5 seconds before starting over with another batch of 10.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .