M HYPE SPLASH
// general

How to use /k to keep a command prompt shortcut from closing?

By Emma Terry

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

2 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 25565

Note: %COMSPEC% will resolve to cmd.exe

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy