Google Answers Logo
View Question
Q: Running Command Prompt & automatically running a command ( Answered 5 out of 5 stars,   4 Comments )
Subject: Running Command Prompt & automatically running a command
Category: Computers > Operating Systems
Asked by: applecore-ga
List Price: $3.00
Posted: 30 Sep 2004 09:14 PDT
Expires: 30 Oct 2004 09:14 PDT
Question ID: 408399
I would like to be more efficient. Start>>Run... remembers commands
run there. I do Start>>Run... ==> cmd ==> Enter ==> ipconfig' many
times per week.

I'd like to know how I can run 'Start>>Run... ==> cmd -K ipconfig' (OR
SOMETHING LIKE THAT) instead. This will save me the typing of ipconfig
over and over from the same computer.

For a bonus, tell me how to fill the following command with 'exit',
but wait for me to hit enter to close.

Or outside of the box, please tell me another technique to make this
even quicker...

I've searched 5min for this, I'm curious what search terms you'll use.
The 'K' switch maybe should have worked, but it doesn't.

Thanks, Good Luck,
Subject: Re: Running Command Prompt & automatically running a command
Answered By: aht-ga on 30 Sep 2004 23:23 PDT
Rated:5 out of 5 stars

Since you insisted, I will post this as an Answer, with a bit of
additional information as well.

The comment from dimprofi-ga definitely meets your immediate needs.
Placing the various commands that you would normally type into a batch
file saves you from having to type them each and every time; using
'pause' as the last command allows you to choose when to close the
output window containing the results of those commands.

A good primer to refresh your memory on all that can be done in/with a
batch file is: 

(which incidentally is the first hit when you search for "batch files")

If you really want to dive deeper into batch files, then you can check out:

The Ancient Art of DOS Batch Files


The alternate method I described in my comment, is to take advantage
of the capabilities of the CMD.EXE command. You can see the available
parameters for the CMD.EXE command by opening up a command prompt,
then typing "cmd /?". In particular, with the /c parameter, you can
pack the contents of a batch file into a single command line, such as:

   cmd /c "ipconfig /all | more && ping && pause"

When used with capabilities such as piping ( | ) to the ''
command, and even the 'start' command to work with other Windows
programs, you can accomplish just about anything with a single command
line. Just remember that there is a maximum command line length; back
in the MS-DOS days, it was a measly 127 characters. Windows 95 allowed
up to 250 (that's 254 less the minimum path-length of 4 characters).
Technically, the version of CMD.EXE in W2K and XP can handle up to
8192 characters.

An easier way to study what the CMD.EXE command can do, is to read the
documentation on the Microsoft website:

Hope that this helps!


Google Answers Researcher
applecore-ga rated this answer:5 out of 5 stars and gave an additional tip of: $2.00
Rock solid. You two teamed together well. Dropped the big suplex on
me. Thank you. This is improving my life immensely. Efficiency will
soon be mine. And from there, THE WORLD!!!

Subject: Re: Running Command Prompt & automatically running a command
From: dimprofi-ga on 30 Sep 2004 09:25 PDT
Create a new file "job-1.bat" somewhere on your PC.
Write with notepad this text in it:

ipconfig /all

Save this file.
Now make a shortcut to this file on the desktop.
Start Shortcut and u will see.

"pause" is a command to wait for a key press.
Subject: Re: Running Command Prompt & automatically running a command
From: applecore-ga on 30 Sep 2004 10:40 PDT
I accept this as the answer, and have a high% bonus waiting for
dimprofi-ga. Thanks!

Here's what I can say about this:
"Hi, my name's dimprofi-ga, and I'll be instructing the batch-file 101
class today. Some of you may be skilled programmers with BLINDERS ON
to the world, so the remedial information I'm providing may seem
obvious once you see it. Still, you'll get a lot of value out of this
course, and I can say with certainty you will be satisfied with your

Thanks my new genius friend. Can I pay you please?
Subject: Re: Running Command Prompt & automatically running a command
From: aht-ga on 30 Sep 2004 12:24 PDT
Hi applecore-ga:

Glad to see that dimprofi-ga's comment helped you out! As dimprofi-ga
is not a Google Answers Researcher, he/she will not be able to post
the comment as the Answer; you can consider any comments posted to any
question as a freebie.

In addition to Batch Files 101, though, you might find the following
helpful too. Let's say that you always use "ipconfig /all" to view the
complete info for all of your network adapters, and that you want to
follow that up with some additional commands like ping or tracert. You
can use a batch file for this, or you can even type the following in
the Start>Run window:

  cmd /c "ipconfig /all | more && ping && pause"

The /c parameter tells cmd.exe to close the window after it is done
processing the string that follows. The string in turn does the
following commands:
  - launches 'ipconfig /all' and pipes (|) the output to '' so
that it automatically pauses at the end of each screen of text
  - the '&&' is the in-string separator for the next command
  - 'pause' waits for any keypress

You can place this cmd line into a batch file, such as cmd1.bat, and
put the batch file in a folder that is in your path, such as the
SYSTEM32 directory in your Windows or WINNT folder; then, you can run
it just by typing 'cmd1' in Start>Run, or use a shortcut as
dimprofi-ga's comment mentions. Using this method (and the pipe to
'more'), you can use any of the text-based commands that are still
built into Windows today.


Google Answers Researcher
Subject: Re: Running Command Prompt & automatically running a command
From: applecore-ga on 30 Sep 2004 13:57 PDT
aht-ga: If you're a paid researcher, can I pay you for the excellent
addition (command line 102 if you will), and you just owe dimprofi-ga
half for a while?

I LOVE getting something for nothing, but I believe that good karma
should be rewarded. Please let me pay someone for this assistance!
Does Google Answers take a cut of the profit, or just the $0.50
listing fee?

Thanks again! GA ROCKS!!!

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy