Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

In Office programs, you receive a "Specified COMMAND search directory had too many parameters" error message when you try to use an MS-DOS core command from the Shell function


View products that this article applies to.

This article was previously published under Q213800

↑ Back to the top


Symptoms

In Microsoft Office, when you use the Shell function in a Visual Basic for Applications macro to execute an external MS-DOS command, an MS-DOS window may open and you may receive the following error message:
Specified COMMAND search directory had
Too many parameters
The MS-DOS window is fully functional and the command you were attempting to run from the macro can be successfully run from the MS-DOS prompt. The commands that return this error message are the following:
  • DIR
  • CLS
  • DEL
  • CD
  • MD (MKDIR)
  • RD (RMDIR)
  • COPY

↑ Back to the top


Cause

This behavior occurs if you have not used the /c switch in the macro. The /c switch is required to properly execute MS-DOS commands in a Visual Basic for Application macro.

↑ Back to the top


Resolution

To resolve this behavior, add the /c switch after command.com. For example to create a new directory called mydir, use the following code in a macro:
Shell "command.com /c md c:\mydir"
				
Note the /c switch after command.com.

↑ Back to the top


More information

You can perform most of the commands that are provided by command.com through statements and functions included in Microsoft Visual Basic for Applications. Some common core MS-DOS commands and their Microsoft Visual Basic equivalent statements are listed below.

MS-DOS       Visual Basic Statement/function

DEL          Kill 
CD           ChDir 
MD           MkDir 
RD           RmDir 
COPY         FileCopy 
DIR          Dir
				


Note For the correct syntax to use each Visual Basic statement, look up the statement in the Microsoft Visual Basic help. For example, to learn how to use Kill, type kill in the Answer Wizard and click Search.

↑ Back to the top


Keywords: kbdtacode, kberrmsg, kbprb, kbprogramming, KB213800

↑ Back to the top

Article Info
Article ID : 213800
Revision : 8
Created on : 2/8/2007
Published on : 2/8/2007
Exists online : False
Views : 477