Share via


Shell Command

Launches executable programs from within Visual Studio.

Tools.Shell [/command] [/output] [/dir:folder]path[args]

Arguments

  • path
    Required. The path and file name of the file to execute or the document to open. A full path is required if the specified file is not in one of the directories in the PATH environment variable.
  • args
    Optional. Any arguments to pass to the invoked program.

Switches

  • /command or /c or /cmd
    Optional. Specifies that the output for the executable is displayed in the Command window.
  • /dir:folder or /d:folder
    Optional. Specifies the working directory to be set when the program is run.
  • /output or /o or /out
    Optional. Specifies that the output for the executable is displayed in the Command Output pane of the Output window.

Remarks

The /dir /o /c switches must be specified immediately after Tools.Shell. Anything specified after the name of the executable is passed to it as command line arguments.

The pre-defined alias Shell can be used in lieu of this command.

Caution   If the path argument supplies the directory path as well as the file name, you should enclose the entire pathname in adjacent double quotes, as in the following:

  Tools.Shell """c:\Program Files\SomeFile.exe"""

Each pair of adjacent double quotes ("") within the string literal is interpreted as a single double quote character in the string. Therefore, the preceding example passes the following string to the Shell command:

  "c:\Program Files\SomeFile.exe"

If you do not enclose the above path in adjacent double quotes, Windows will look for a file called Program.exe in the C:\ directory. If such a program had been installed at that location, for example by illicit tampering, it would be executed instead of SomeFile.exe in the C:\Program Files directory.

Example

The following example lists the full paths of documents in the "My Documents" folder in the Output window.

>Tools.Shell /output cmd /c dir /s /b """c:\My Documents\*.doc"""

See Also

Visual Studio Commands with Arguments | Command Window | Find/Command Box | Pre-defined Visual Studio Command Aliases