In this section you will find a collection of scripting techniques and best practices for batch files.
Most of these techniques apply to either "DOS batch" (also related to as "real DOS" batch or "true DOS" batch), or "NT batch", only in rare cases to both.
If you want to use "true DOS" batch techniques in Windows NT 4 or later (2000, XP, Server 2003, Vista) you may have to invoke these batch files with COMMAND/C.
Check the "classification" for a batch technique by hovering your mouse pointer over the information icon at the left of the titles before asking why a batch file doesn't work in your environment.
WMIC
WMI queries from the command line.
WMI(C) is software/OS oriented, and is known to sometimes return incorrect values for hardware queries (e.g. SATA/IDE/SCSI, serial ports, multiple monitors and screen resolutions).
Reports can be created by redirection only.
MSINFO32.EXE is one of Windows' native inventory tools.
It is usually located in the folder %ProgramFiles%\Common Files\Microsoft Shared\MSInfo.
Without command line arguments it will run in GUI mode.
Type MSINFO32 /? for a list of available command line arguments.
Reliability is not better than WMI(C)'s, but in some cases MSINFO32's command line may be preferred over WMIC's.
For reports, use the /REPORT switch.
DXDIAG.EXE is Windows' native DirectX diagnostic tool.
It is usually located in the %windir%\System32 directory.
Without command line arguments it will run in GUI mode.
Type DXDiag /? for a list of available command line arguments. DXDiag is much more reliable than WMIC and MSINFO32 when it comes to video and sound hardware, but it is also much slower, and it can be used for the local computer only.
Reports can be saved in plain text (/t switch) or XML (/x switch)
Batch HowTos
An new collection of batch file scripting techniques, most of them for Windows NT 4 and later only.
How To ...
A really old collection of batch file scripting techniques, most of them for MS-DOS only.
The page will be opened in a new window because the frameset is incompatible with the DHTML menu and the stylesheet switcher.
Poor man's admin tools
A collection of scripts that can be used to replace resource kit utilities or commands no longer available in recent Windows versions.
Solutions found on alt.msdos.batch
Several clever scripting solutions from the alt.msdos.batch and alt.msdos.batch.nt newsgroups.
Most of these are from the previous millennium, but still hold their own.
Parsing DATE and TIME in NT
How to extract the day, month, year, hours, minutes; andvanced syntax and some not-so-basic examples of date math in CMD.EXE.
Advanced Date Math in NT
Add days or weeks to the current day, subtract days or weeks, find the timespan between two dates, find the weekday of any date.