Re: Conditional execution using DOS batch file



On 3 Oct 2005 00:35:27 -0700, sbillore@xxxxxxxxxxxxxx wrote:

>Hi All,
>
>I am new to DOS batch programming.
>My aim is to define some config.h file.
>This file will contain some #define.
>Based on each #define i want to run some
>dos command.
>
>It is possible to write DOS batch file to do so?
>
>How we can include this config.h into DOS
>batch file then based on #define perform some
>DOS command execution.
>My hypothetical batch file would be:
>
>----------
>#include config.h
>
>#ifdef VAR1
>DOS command1
>DOS command2
>#endif
>
>#ifdef VAR2
>DOS command3
>DOS command4
>#endif
>----------

That's not the way batch files work. If you want to include something
in a batch file, you make it another batch file and CALL it.

There is no IFDEF in DOS (including Win9x), though there is something
similar in NT/W2K/XP batch language. Assuming that the variables in
question are environment variables, there are ways to manage the
program flow, but they vary depending on the operating system it's
for.

This group is primarily for highlevel, and perhaps assembly, languages
under real DOS. Your question is more properly asked in one of the
batch groups: alt.msdos.batch or alt.msdos.batch.nt, depending on
which operating system you are using.

The IF help ( IF /?) pretty much covers the basics, regardless of the
operating system.

--
T.E.D. (tdavis@xxxxxxxxxxxxxxxxxxxx)
SPAM filter: Messages to this address *must* contain "T.E.D."
somewhere in the body or they will be automatically rejected.
.



Relevant Pages

  • Re: Multi-zip files -- Windows server
    ... native DOS versions). ... TO BATCH OR NOT TO BATCH ... and using a batch file to try and solve the problem... ... The IBM PC operating system command line is a most ...
    (comp.sys.cbm)
  • Beginners questions: running programs
    ... I'm currently interested in learning vbscript for the same purposes as ... batch language: manipulating files and running programs from a DOS ...
    (microsoft.public.scripting.vbscript)
  • Re: An end to tweaking?
    ... > Batch File Lab Notes, which had so much info it boggled my mind. ... Doing /anything/ recursive with DOS batch makes my head hurt. ... bash (the default shell under Linux) is /much/ better than ... You can save that to a file and it will be a first-class command from then ...
    (comp.os.linux.misc)
  • Re: Search c drive and copy files of a certain extension
    ... to a standard maintenance problem that can be resolved in a single line ... his head at your "verbose" DOS. ... a 1 line batch script wasnt really an option because user permissions ...
    (microsoft.public.scripting.vbscript)
  • Re: Terminal Server 2003 Sessions dont close when exiting a DOS application
    ... Did you change to the batch file's properties to "Close on Exit"? ... End a disconnected Session after: ... partiular DOS program you will only affect those users - not everyone... ... >> Terminal Services using Windows Server 2003. ...
    (microsoft.public.windows.terminal_services)