Solved

echo command in .bat files

Posted on 2004-10-03
12
441 Views
Last Modified: 2013-11-18
hello
when i create a bat file, and let's say i use this command:
echo "hello world"
when i open the bat file, the cmd box will open for less than a second. i'd like it to open and stay there, saying "hello world". is that possible?

second question, what command let's the bat file recognize if the user typed a letter? because there are bat files i saw that say first "please type anything to continue", how do i do that?

thank you very much
0
Comment
Question by:urzica
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 12210577
Hi urzica,

Sure, just do this:

echo "hello world";
pause

Regards,
Zyloch
0
 
LVL 4

Author Comment

by:urzica
ID: 12210598
hi zyloch, thanks for ur quick reply (again).
the thing is, i did what u said, and it comes out this way:
C:\> echo hello world
hello world
C:\>pause
press any key to continue

i'd like these lines not to appear:
C:\> echo hello world
C:\>pause

that's the whol;e idea i dont want it to show my commands.. i dont think it's supposed to.. :\
this is the batch file:
echo hello world
pause

what am i doing wrong?
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 50 total points
ID: 12210604
Do this:

@echo off
echo "hello world"
pause
echo on
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Author Comment

by:urzica
ID: 12210607
thank you very very much, exactly what i needed. can u just explain why is it that way? what is this echo off\on @ thing? thanks again
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12210611
Well, echo off turns of command echoing. You can still echo text, but your commands don't get echoed. Just like how in PHP, you can turn off error_reporting for the whole script, you can use @ to turn error_reporting off only for certain functions, you do the same with the batch.

Because the first echo off command would be echoed normally, (since at that time, echo isn't off), you'd have to put the @ to stop that echoing.
0
 
LVL 4

Author Comment

by:urzica
ID: 12210617
thanks again
0
 
LVL 4

Author Comment

by:urzica
ID: 12210641
if i understand u correctly, this:
@echo off
echo "hello world"
pause
echo on

is equal to this:
@echo "hello world"
@pause
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12210645
Absolutely, but for bigger files, you'll want the @echo off
0
 
LVL 4

Author Comment

by:urzica
ID: 12210655
yeah, logical.. thx a bunch, and i'd like to langthen ur misery here with me once more please :\

last question life-saver!
is there a way to del or do anything to shortcuts? when i say do
del "C:\User\Desktop\regedit.exe"
it wont do it becuz it's a shortcut. it will do it to any other regular application.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12210668
Don't know if it will work, but try:

del "C:\User\Desktop\regedit.lnk"
0
 
LVL 4

Author Comment

by:urzica
ID: 12210673
you did it again :)))
ur great thanks so much
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 12210675
No prob :)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question