Re: batch question

Tech-Archive recommends: Fix windows errors by optimizing your registry



See below.

"David K" <noemails@xxxxxxxxxx> wrote in message
news:OCqyG8P8GHA.3384@xxxxxxxxxxxxxxxxxxxxxxx
Pegasus (MVP) wrote:
"David K" <noemails@xxxxxxxxxx> wrote in message
news:u73WmgO8GHA.3960@xxxxxxxxxxxxxxxxxxxxxxx
Pegasus (MVP) wrote:
"David K" <noemails@xxxxxxxxxx> wrote in message
news:eww68BO8GHA.608@xxxxxxxxxxxxxxxxxxxxxxx
When I use the ping command in a batch file the
command is displayed over and over in the CMD
window at great speed, without being executed.

The batch files are textfiles called filename.bat,
stored on the Windows XP desktop and invoked by
mouse clicks.

ping ip-address
ping ip-address -t

both exhibit this problem.

Other commands such as tracert do not have this problem.

Any ideas?

David K
Melbourne.au
This is not a "problem" but is the way batch files work.
You can easily overcome it by coding like so:

@echo off
ping ip-address
ping ip-address -t
echo Press the Space Bar to close this window.
pause > nul


Thanks for replying, Peg

'echo off' prevents display to the screen, making it useless :)
I can't see any other change that you've made.

all I want is for the command to work inside a command prompt window.
as aforementioned, the tracert command works as expected.

If I type the same command 'ping ip-address' from within a dos window,
it works fine.

Cheers

David Kinston

Well, if you don't like "@echo off", omit it!

You write "I can't see any other change that you've made."
Your original batch file had two lines. Mine has 5. Spot
the difference - it's essential!



Your sarcasm is much appreciated, mate.

I'm afraid you asked for it.

The differences consisted of 2 ping commands (only 1 is needed)
plus a termination routine which is never executed. I did
actually note them.

If these commands are never executed then I suspect that
you fell into a well-known trap: you are not executing ping.exe
but instead your own batch file called "ping.bat". Do not ever
call a batch file by the same name as a system program - it
causes lots of confusion!

The first thing I did was to try out your solution - it resulted
in a blank DOS window which simply stayed put - no doubt scrolling
madly albeit invisibly without terminating.

I beg to disagree. However, unless you post the
version you actually ran, I cannot comment any
further. Let's have a look at it!

Is that what you were aiming to achieve?

No, not at all. The line

echo Press the Space Bar to close this window.

will write a message to the screen, and this line

pause > nul

will pause the process until you press just about any key.

If not, please consider how to create a batchfile which can be
invoked by calling or clicking, which performs the ping
command in a window, acting in the normal expected way.

In the past I have had no difficulty doing this sort of thing.

Thanks again

David K
melbourne.au

To resolve the matter, do this:
- Post your batch file.
- Start a Command Prompt (Start / Run / cmd {OK})
- Type the name of the batch file, e.g. "c:\Tools\MyBatch.bat" {Enter}
- Report exactly what happens.

Pegasus
Balwyn 3103


.



Relevant Pages

  • Re: Batch File Problem - Batch File Enclosed
    ... I have added a batch file to my Startup folder to execute whenever ... The batch file works ok but it leaves a blank command ... I would like close this window using the batch file ...
    (microsoft.public.windowsxp.general)
  • Re: Execute a batch file and wait for it to complete
    ... and until I manually close the console. ... Starts a separate window to run a specified program or command. ... If it is an internal cmd command or a batch file then ...
    (comp.lang.fortran)
  • Build instructions for loadcepc.exe
    ... Build instructions for loadcepc.exe ... a standard cmd.exe window. ... Execute the batch file setupenv.bat: ... command promt ...
    (microsoft.public.windowsce.platbuilder)
  • Build instructions for loadcepc.exe
    ... Build instructions for loadcepc.exe ... a standard cmd.exe window. ... Execute the batch file setupenv.bat: ... command promt ...
    (microsoft.public.windowsce.embedded)
  • Re: Batch File Problem - Batch File Enclosed
    ... I have added a batch file to my Startup folder to execute whenever ... The batch file works ok but it leaves a blank command ... I would like close this window using the batch file ...
    (microsoft.public.windowsxp.general)