Matt said:
wrote in message Is there a tweak that keeps a command prompt open after executing a program from
Windows Explorer? I have several programs that I run from Explorer. They open up
a command prompt window, but the window closes out before I am able to read the
results of the program. <SNIP>
In short, add the cmd /k parameter which tells cmd.exe to carry out the command
specified and continue.
For example, if the program in question is a built-in command-line program such as
Driver Query (driverquery.exe) you would do this:
- Create a shortcut to driverquery.exe
- Right-click the shortcut and click Properties
- Change the target from:
C:\WINDOWS\system32\driverquery.exe
to
cmd.exe /k driverquery.exe
Note 1: Since both programs (cmd.exe and driverquery.exe) reside in a path
(C:\WINDOWS\system32\) defined by an environment variable it is not necessary to use
the complete path to the programs.
Of course, if you are working with a program that does not reside in a path defined
by environment variables you would need to supply the complete path.
An easy way to display the current environment variables is to click Start, click
Run, type the following command and click OK:
cmd /k echo %Path%
For more information about managing environment variables see the following Microsoft
Knowledge Base article:
KB310519 - HOW TO: Manage Environment Variables in Windows XP
http://support.microsoft.com/default.aspx?Product=winxp&scid=kb;en-us;310519
Note 2: If you add the appropriate parameters you can redirect the command output
stream to a text file. For example, say you keep system configuration information
and status reports in the a folder named C:\Computer\Config. And say that you want
to create and save an Analysis Report generated by defrag.exe of your C: partition.
What you would do is create a shortcut in your C:\Computer\Config folder with the
following properties. Then, all you have to do is double-click the shortcut to
generate the report and close the command prompt.
Target: %windir%\System32\cmd.exe /k defrag c: -a -v > defrag.txt & Exit
Start in: C:\MyComp\Config
For a "Command shell overview" and information about "command redirection operators"
search the Help and Support Center for the phrases words in double-quotes.