Solved

echo command in .bat files

Posted on 2004-10-03
12
447 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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

734 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