Return to the technote repository Exit
Operation

Introduction

The Exit Operation (Magic Windows) has the same behavior than the "Run" dialog box in Windows. It is different of previous DOS Magic version, where the behavior was the same than the DOS prompt.

So you can call : executable files (.exe, .com, .bat) or files with registered extensions (.wri, .txt, .htm, ... - you don't need to call the application) ; but you can't call DOS internal commands (dir, mkdir, copy, ...).

Dos Batch

My recommendation to call DOS commands (ie DOS internal commands and DOS applications) are :

  • Always use a .bat. So the correct command interpreter will be called. The command interpreter is command.com under DOS/Windows 9#, but it is cmd.exe under Windows NT. The COMSPEC environment variable is also set to the correct interpreter, but i found it safer and easier to always use a .bat. Also DOS commands can differ between Windows and NT, so test them before deploying.
  • The .bat should begin with @echo off and ending with @cls (see Microsoft Kbase Q152682). This precaution force the dos box to close, even if the .pif option "Close window on exit" is set to No. So you don't have to provide a doscall.pif (doscall.bat is your DOS batch). If no .pif is found, the _default.pif (in the Windows folder) is used, and this setting may be changed by the user !

For instance, to make a dir, you used in DOS days the dir > list.txt. Now you should use the following batch file :

@echo off
dir /b > list.txt
@cls

So the window will close automatically, the correct command interpreter will be used. The /b flag output only the file names, because the output format is different between DOS and Windows versions.

Conclusion

DOS calls are costly in Windows environment, especially with Windows NT. Actually, make a DOS call in Windows is a bit like launching a DOS computer. So a better solution is to use Windows functions, by using a DLL such as GET.DLL, where i have put several replacement for DOS calls (dir functions, mkdir, rmdir, deltree, cat, get_file_attributes,... and Magic provide functions like iocopy, ioexist, iodel, ioren, iosize, ...).