Microsoft KB Archive/212085

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

Article ID: 212085

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



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:

https://partner.microsoft.com/global/30000104

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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:  Start Microsoft Word 2000 and then open the document you want, or create a new document. Press ALT+F11 to start the Visual Basic Editor. On the Insert menu, click Module.  In the module sheet, type the following code: Sub dos_test Shell "command.com /c md c:\newdir" End Sub  Press ALT+Q to return to Word. On the Tools menu, point to Macro, and then click Macros.</li> Select dos_test, and then click Run.</li> 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.</li></ol>

<div class="references_section">