echo command in .bat files

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
LVL 4
urzicaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
ZylochConnect With a Mentor Commented:
Do this:

@echo off
echo "hello world"
pause
echo on
0
 
ZylochCommented:
Hi urzica,

Sure, just do this:

echo "hello world";
pause

Regards,
Zyloch
0
 
urzicaAuthor Commented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
urzicaAuthor Commented:
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
 
ZylochCommented:
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
 
urzicaAuthor Commented:
thanks again
0
 
urzicaAuthor Commented:
if i understand u correctly, this:
@echo off
echo "hello world"
pause
echo on

is equal to this:
@echo "hello world"
@pause
0
 
ZylochCommented:
Absolutely, but for bigger files, you'll want the @echo off
0
 
urzicaAuthor Commented:
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
 
ZylochCommented:
Don't know if it will work, but try:

del "C:\User\Desktop\regedit.lnk"
0
 
urzicaAuthor Commented:
you did it again :)))
ur great thanks so much
0
 
ZylochCommented:
No prob :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.