The msDOScommand class, written in Visual Basic.Net, executes MS-DOS commands and provides both status and results.
Features:
* A guarantee that results are complete as a string from each of one or more MS-DOS commands. This is provided by terminating each MS-DOS command in a submitted batch with a dummy file create command. The existence of the dummy file (which is erased by default) proves when tested by msDOScommand that your prior commands executed...avoiding the very dangerous phenomenon of random failures in MS-DOS calls.
* Full thread safety which means that while one instance CANNOT issue more than one command for competing execution, you can access the Status property of this class while waiting for an MS-DOS job, and perform other work while waiting for the command.
You can download the msDOSCommand code here (2MB zip file) [1].
Of course, there is no such thing as MS-DOS in a forensic sense and the existence of this particular black hole has long been a scandal of Windows. Since Windows is proprietary, the formal existence of the green screen world is fabular, spoken about in hushed terms around de campfire as The Land that Time Forgot into which developers have wandered never to return.
It has historically been difficult to convince many computer users that a GUI-based OS needs a line by line interface at all, since industrial specialization convinces us that anything so apparently peripheral must be a waste of our time. The notion of levels of an OS in which a GUI is naturally an evolution from a still existent green screen of line by line commands becomes as dangerous as biological evolution, and the user prefers to think of digital phenomena as *sui generis*, and that Intelligent Designers at Windows developed Windows in six days, and that on the Seventh day, they rested.
MS-DOS becomes like sex unmentionable despite the fact that many programs continue to issue MS-DOS commands in a cybernetic back alley. msDOScommand is my humble attempt to make explicit and hence safer the process of my own emission of MS-DOS commands in a follow-on project I am working on, to replace the Windows search command with the little puppy dog with something both faster, and more dignified, that isn't broken, as Windows search seems to be, by the use of international and otherwise non-standard file identifiers.
The forbidden land, the Land Before Time, of MS-DOS is constituted only by the existence of legacy but possibly ineradicable-in-future-releases command such as the shell() command of VB.Net, which is the only facility used by this class to issue commands to MS-DOS (if shell() disappears, this class won't work anymore).
MS-DOS becomes like an old dusty VCR recording of Mom and Dad having sex in 1983. This means that the shell() command is issued with shame, and this shame itself causes bugs. "Programming on purpose", in a phrase of P. J. Plauger, becomes impossible.
Because of the need to deal with potential folklore, this class makes minimal committments and as described above, creates an extra work file (subsequently erased) to make sure insofar as is possible in a nonstandard proprietary environment that the command submitted actually worked.
Pragmatically, and the above intemperate remarks aside, the class removes the VB programmer from having to code asynchronous calls to shell() to run MS-DOS commands.
The software as available comes with a comprehensive test form and application for Windows/.Net which allows you to create an msDOScommand instance, inspect it, test it, and so forth.
[2]
Click image for full size.
Also provided are new versions of the windowsUtilities.DLL and the utilities.DLL libraries originally shipped with my book Build Your Own .Net Language and Compiler [3].
msDOScommand was written in accordance with the Core Procedure method I described in Build Your Own [4], therefore instances have a Name, a dispose(), a self-inspect and a test() procedure. This makes instances more trustworthy than many classes.
I do ask that msDOScommand be used ethically. It has no special code for preventing evil commands such as creation of unknown cookies or erasing files. Since you will have the source you can consider adding these safeguards.
You can download the msDOSCommand code here (2MB zip file) [5].