Category Archives: Batch

For Loop in DOS Batch

In batch scripting, you can use a for loop to iterate over a set of values or files. The for loop in batch files has different variations, such as for /F, for /R, and for %%variable. I’ll show you an example of a basic for loop using the for %%variable syntax.

Using @ in Batch Files

In a batch file, the at sign (@) is used as a prefix before a command to suppress its output from being displayed on the console. When a command is prefixed with an at sign, only the output generated by the command is hidden, while the command itself is still executed.

Grabbing System Date in a Batch File

Batch programming can be a powerful thing. Basically, anything you can run at a command prompt can be run in a batch file. Coupled with task scheduler, process automation nirvana can be achieved. However, one thing that is conspicuously is the presence of a date or time variable. For example, if you wanted to date or time encode… Read More »

Automation with Batch Files

If you’re familiar with MS-DOS at all, you’ll recall that it’s a command-driven operating system that performs functions issued at the C:> prompt. The only way to get an MS-DOS computer to do something was to type a command at this prompt and if you can imagine, it was a rather cumbersome way to use a computer.

Batch File to Determine Operating System Version

Many DOS commands in the 32-bit versions of Windows are similar but support different parameters or a few different commands. Thus, if you wish to write a batch file that can run on different types of machines, it may prove beneficial to determine the version of Windows on which the batch file is running. This way the batch… Read More »

Batch file SLEEP Command

Most operating systems provide a command in batch files to sleep, or wait, a certain number of seconds. This is great in that batch files can display text, allowing you time to read before continuing. Or, batch files may wait a few seconds in order to connect to other resources.