Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

echo command in .bat files

Posted on 2004-10-03
12
Medium Priority
?
459 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 200 total points
ID: 12210604
Do this:

@echo off
echo "hello world"
pause
echo on
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

705 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