Solved

echo command in .bat files

Posted on 2004-10-03
12
454 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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

630 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