Batch file

E

Esteban

Hi i would like to know if there's a good place to learn about making
batch file because i don't know about the syntax. I only program in c,
delphi and Java.

What i would like to know is if it's possible to do a "while", "if"
(Conditions) and "read/write" text files so i can do a several test
like ping few computer in my buisness and be sure that they are well
connected by creating a file that after it read the name of the
computer it will ping and it pings it, write a file with the name of
this computer with a "ok" next to it if it worked and "Not connected"
if it can't ping it!

Thanks helping me with batch file programming!

Esteban (sorry my english)
 
D

David Candy

Type if and for in help. Everything else is just what you type at a command prompt.
 
P

Peter Forster [MVP]

Howdie,

Esteban said:
I can't type anything in Ms-Dos Edit batch file program!(Edit.exe)

Why do you use edit.exe?
Use cmd.exe instead.

Regards,

Peter Forster
MVP Windows Server Networking
Austria
 
H

HeyBub

Esteban said:
I can't type anything in Ms-Dos Edit batch file program!(Edit.exe)

At the command prompt, type:

%systemroot%\hh.exe Ms-its:%systemroot%\help\ntcmds.chm::/ntcmds.htm

And you will learn more than you want to know.

Or, again at the command prompt, type "Help" Thereafter, type
"Help/{command}," i.e., "HELP/SUBST"
 
T

Torgeir Bakken \(MVP\)

Esteban said:
Hi i would like to know if there's a good place to learn about making
batch file because i don't know about the syntax. I only program in c,
delphi and Java.

What i would like to know is if it's possible to do a "while", "if"
(Conditions) and "read/write" text files so i can do a several test
like ping few computer in my buisness and be sure that they are well
connected by creating a file that after it read the name of the
computer it will ping and it pings it, write a file with the name of
this computer with a "ok" next to it if it worked and "Not connected"
if it can't ping it!

Thanks helping me with batch file programming!
Hi,

Below is a batch file that should do what you want.
The computerlist.txt file needs to have one computer name
on each separate line.

--------------------8<----------------------
@echo off
setlocal

set inputfile=computerlist.txt
set resultfile=results.txt

del "%resultfile%"

for /F "tokens=*" %%a in (%inputfile%) do call :ping %%a
GOTO :EOF

:ping
set connected=N
for /f "Tokens=*" %%b in ('ping.exe -n 1 %1 ^|find.exe "TTL="') do (
set connected=Y
)
if "%connected%" EQU "Y" echo %1 OK >> "%resultfile%"
if "%connected%" EQU "N" echo %1 Not connected >> "%resultfile%"
GOTO :EOF

endlocal
--------------------8<----------------------


Some batch file/command line resources:

The newsgroup microsoft.public.win2000.cmdprompt.admin is a very
good newsgroup for batch and command line questions.

Windows Scripting and Batch Programming Resources:
http://www.labmice.net/scripting/default.htm

Steve Hardy's web site
http://www.seanet.com/~shardy/ntscript.html

Batfiles. The DOS batch file programming handbook & tutorial:
main site: http://home7.inet.tele.dk/batfiles/
mirror: http://members.fortunecity.com/batfiles/
mirror: http://www.angelfire.com/blues/batfiles/


JSI FAQ, Windows NT / 2000 / XP Tips, Tricks, Registry Hacks and more...
http://www.jsiinc.com


Batfile links:
http://home7.inet.tele.dk/batfiles/main/links.htm
http://www.uwasa.fi/~ts/http/http2.html#batch
http://dmoz.org/Computers/Software/Operating_Systems/x86/DOS/Programming/Languages/Batch/


A newsgroup search is also an incredible source of information :)

You can use http://groups.google.com/advanced_group_search to search
in a news database having articles dated back to all the way to 1981.

Batch programming and command line newsgroups ideal for newsgroup
searches:

alt.msdos.batch
alt.msdos.batch.nt
microsoft.public.win2000.cmdprompt.admin
 
B

billious

Esteban said:
Hi i would like to know if there's a good place to learn about making
batch file because i don't know about the syntax. I only program in c,
delphi and Java.

What i would like to know is if it's possible to do a "while", "if"
(Conditions) and "read/write" text files so i can do a several test
like ping few computer in my buisness and be sure that they are well
connected by creating a file that after it read the name of the
computer it will ping and it pings it, write a file with the name of
this computer with a "ok" next to it if it worked and "Not connected"
if it can't ping it!

Thanks helping me with batch file programming!

Esteban (sorry my english)

You could try these newsgroups

microsoft.public.win2000.cmdprompt.admin
alt.msdos.batch

but probably the best would be

alt.msdos.batch.nt

HTH

....Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top