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.

  1. Right-click where you want the shortcut created and choose New Shortcut.

  2. Type cmd.exe /k string, where string is the command you want to execute, then click Next.

  3. Give the shortcut an appropriate name and click Finish.

Get Windows 2000 Quick Fixes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.