How to use /k to keep a command prompt shortcut from closing?
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 25565My target field looks like this:
"C:\Windows\System32\PING.EXE" /k 10.98.56.1 -t -I 25565But 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?
12 Answers
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 25565Note: %COMSPEC% will resolve to cmd.exe
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.1The -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
exitThen you could call that batch file with the shortcut:
"c:\folder\batchfile.bat" 192.168.1.1Of 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 :loopWhich uses the -n argument to ping 10 times, then does a timeout for 5 seconds before starting over with another batch of 10.