Execute a command from a shortcut but have the window remain open
When you execute a shortcut associated with a
console command
(xcopy
,
dir
, etc.) the
command executes and the console windows closes on completion. This
means you can’t see the results of the command. In many cases
you probably will want to keep the window open, if for no other
reason than to verify that the command performed its intended
function without errors.
Run the application using a shortcut to cmd /k
Rather than execute the command from a shortcut to its own
executable, create a shortcut to cmd.exe with
the /k
switch that will keep the window open
when the command completes execution.
Right-click where you want the shortcut created and choose New → Shortcut.
Type
cmd.exe /kstring, wherestringis the command you want to execute, then click Next.Give the shortcut an appropriate name and click Finish.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access