WD2000: Window Stays on Screen When You Use a Shell to Start an MS-DOS Program (212085)



The information in this article applies to:

  • Microsoft Word 2000

This article was previously published under Q212085

SYMPTOMS

If you use the Shell command to run an MS-DOS program, the MS-DOS window remains on the screen, and you must manually close the window.

CAUSE

The Close On Exit property is not set for the MS-DOS window.

WORKAROUND

To work around this behavior, use either of the following methods.

Method 1

  1. Start the MS-DOS prompt (click Start, point to Programs and then click MS-DOS Prompt).
  2. On the toolbar, click the Properties button.
  3. On the Program tab, click to select the Close on exit check box and then click OK.

Method 2

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: You can programmatically start the MS-DOS command interpreter, Command.com, with the /c switch (the /c switch must be used or the code may not run as expected). This switch closes the window after the program quits. For example, to create a new folder named Newdir, follow these steps:
  1. Start Microsoft Word 2000 and then open the document you want, or create a new document.
  2. Press ALT+F11 to start the Visual Basic Editor.
  3. On the Insert menu, click Module.
  4. In the module sheet, type the following code:
    Sub dos_test()
       Shell "command.com /c md c:\newdir"
    End Sub
    					
  5. Press ALT+Q to return to Word.
  6. On the Tools menu, point to Macro, and then click Macros.
  7. Select dos_test, and then click Run.
  8. Use Windows Explorer to look at the folders under drive C; notice that there is a new folder named Newdir. Note that the MS-DOS window is not open.

REFERENCES

For help with Command.com switches, start the MS-DOS prompt, type command /? and then press ENTER.

Modification Type:MajorLast Reviewed:5/13/2002
Keywords:kbprb KB212085