🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #633

DOS Commands

#633
From: Mikael Wahlgren
Date: Tue, 07 Apr 1992 23:31
30 lines
1577 bytes
Following is an example program of how to use the DOS.SYS driver to execute
a command in the OS/2 1.3 DOS compatibility box (I haven't tested how it
works in OS/2 2.0, as there are better means to do this in 2.0).  Note, that
you will need to  switch to the DOS box, before the command is actually
executed.  This could be done automaticly by using the WinQuerySwitchList and
WinSwitchToProgram API, or manually.  If you need an example on how to do
this, I can post this too, but in that case you will have to accept Modula-2
code instead.  The following example is written in C and compiled with
JPI TopSpeed C++ (but there shouldn't be any specific for that compiler:-)

#include <stdio.h>
#include <string.h>

void dosCmd(char *cmd) {
  FILE          *dosdrv;

  if ((dosdrv = fopen("DOS$", "w")) != NULL) {
    fprintf(dosdrv, "%c%c%s%c%c", 128, 32, cmd, 13, 0);
    fclose(dosdrv);
  } else {
    printf("Failed to access DOS box!\n");
    printf("Check that DOS.SYS is loaded and PROTECTONLY=NO in your CONFIG.SYS!\n");
  }
}

void main(void) {
  dosCmd("DIR");
}

Mikael Wahlgren      d9mikael@dtek.chalmers.se
Technical Details
Message-ID: <10858@chalmers.se>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!rutgers!micro-heart-of-gold.mit.edu!bloom-beacon!eru.mt.luth.se!lunic!sunic!chalmers.se!dtek.chalmers.se!d9mikael

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!rutgers!micro-heart-of-gold.mit.edu!bloom-beacon!eru.mt.luth.se!lunic!sunic!chalmers.se!dtek.chalmers.se!d9mikael
From: d9mikael@dtek.chalmers.se (Mikael Wahlgren)
Newsgroups: comp.os.os2.programmer
Subject: DOS Commands
Message-ID: <10858@chalmers.se>
Date: 7 Apr 92 23:31:04 GMT
Sender: news@chalmers.se
Organization: Chalmers University of Technology
Lines: 30