954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Question about DOS Batch Files

I'm a newbie at writing DOS batch files. I've tried to look for it, but I can't seem to figure out how to read from an input file. Is there an equivalent of a cin statement in DOS Batch programming.

AJ_Allmendinger
Newbie Poster
2 posts since Sep 2005
Reputation Points: 10
Solved Threads: 0
 

Batch files are just a way of grouping together calls to programs and system commands. Everything in a batch file is just something that you can do on the command line. The power comes from being able to group together numerous calls to execute a series of steps. If you are creative in how you use the tools that you have access to, you can create some seemingly intelligent behavior.

I have a feeling that you may be expecting too much out of batch files, but it could be possible to do what you want. What exactly is it that you want to do?

chrisbliss18
Posting Shark
917 posts since Aug 2005
Reputation Points: 38
Solved Threads: 25
 

You're right, I was expecting too much... I worked around it by having the autoexec.bat call a C++ program that served as a batch file except with more functionality.

Thanks....
AJ

AJ_Allmendinger
Newbie Poster
2 posts since Sep 2005
Reputation Points: 10
Solved Threads: 0
 

What you might want to do is install something like Python or Ruby and write your scripts in that.
No need for compilers.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

Compiled languages seem to be fading. :p
Yeah I heard ruby was good too tho.

The_Inferno
Newbie Poster
10 posts since Sep 2005
Reputation Points: 10
Solved Threads: 0
 
I'm a newbie at writing DOS batch files. I've tried to look for it, but I can't seem to figure out how to read from an input file. Is there an equivalent of a cin statement in DOS Batch programming.

Some people have figured out how to do quite a good bit of processing work via batch files: ftp://137.193.64.130/pub/

Evenbit
Junior Poster
140 posts since Mar 2005
Reputation Points: 99
Solved Threads: 5
 
What you might want to do is install something like Python or Ruby and write your scripts in that. No need for compilers.

Or you can install AutoIt. And you can optionally compile & compress your scripts too if you don't want to force your clients to download a runtime engine.

Evenbit
Junior Poster
140 posts since Mar 2005
Reputation Points: 99
Solved Threads: 5
 
Compiled languages seem to be fading. :p Yeah I heard ruby was good too tho.

No...the pendulum is swinging back the other way now. When was the last time that CPU clock speed doubled? As users continue to demand more functionality and more eye-candy multimedia, it will be up to the software to pull it off -- and that can't be done with interpreted languages and virtual machines.

Evenbit
Junior Poster
140 posts since Mar 2005
Reputation Points: 99
Solved Threads: 5
 

you can do simplistic read ins to a variable using
set /p var="display: "

From my experience batch is extremely limited. You can do simple things but that's about it. For example, if you've ever tried using conditionals in a for loop in batch you'd understand that inside conditionals are evaluated before the for loop executes. Your cout for batch is echo which is extremely limited in that it always returns a \n at the end of its output. There is a workaround set /p var=" " < NUL but still batch is more trouble than its worth.

Dundir
Newbie Poster
3 posts since Nov 2010
Reputation Points: 4
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You