Solved

echo command in .bat files

Posted on 2004-10-03
12
423 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
  • 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
The viewer will learn how to count occurrences of each item in an array.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now