Visual Studio
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

/commandwindow [or] /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.

/outputwindow [or] /output [or] /out [or] /o

Optional. Specifies that the output for the executable is displayed in 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 predefined alias Shell can be used in place of Tools.Shell.

Caution noteCaution:

If the path argument supplies the directory path as well as the file name, you should enclose the entire pathname in literal quotes ("""), as in the following:

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

Each set of three double quotes (""") is interpreted by the Shell processor as a single double quote character. Thus, the preceding example actually passes the following path string to the Shell command:

  "C:\Program Files\SomeFile.exe"
Caution noteCaution:

If you do not enclose the path string in literal quotes ("""), Windows will use only the portion of the string up to the first space. For example, if the path string above were not quoted properly, Windows would look for a file named "Program" located in the C:\ root directory. If a C:\Program.exe executable file were actually available, even one installed by illicit tampering, Windows would attempt to execute that program in place of the desired "c:\Program Files\SomeFile.exe" program.

Example

The following command uses xcopy.exe to copy the file MyText.txt into the Text folder. The output from xcopy.exe is displayed in both the Command Window and the Output window.

>Tools.Shell /o /c xcopy.exe c:\MyText.txt c:\Text\MyText.txt
See Also

Reference

Tags :


Community Content

MoneyJ
The example shows single quotes but says to use double quotes?

In 2008 Visual Studio Document Explorer, I'm seeing single quotes in the code examples, but when I paste the copied code it is showing up as double quotes. This was confusing to me because the documentation said use double quotes and the code example showed single quotes.

I can't put a screen shot in here. but there are three single quotes - ['''] as opposed to ["""]

update...

I was a little confused until i just pasted the following snippets in this annotation...


If the path argument supplies the directory path as well as the file name, you should enclose the entire pathname in literal quotes ("""), as in the following:

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



Update 2:

  

>Tools.Shell /commandwindow /outputwindow """C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\uuidgen.exe"""

The operation could not be completed. The system cannot find the file specified.

>Tools.Shell /commandwindow /outputwindow '''C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\uuidgen.exe'''

The operation could not be completed. The parameter is incorrect.


However, the following works..

>Tools.Shell """notepad.exe"""
  

Page view tracker