Export (0) Print
Expand All

Environment.CommandLine Property

Gets the command line for this process.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public:
static property String^ CommandLine {
	String^ get ();
}
/** @property */
public static String get_CommandLine ()

public static function get CommandLine () : String

Property Value

A string containing command-line arguments.

This property provides access to the program name and any arguments specified on the command line when the current process was started.

The program name can include path information, but is not required to do so. Use the GetCommandLineArgs method to retrieve the command-line information parsed and stored in an array of strings.

Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: The name of the executable file does not include the path.

Windows 98, Windows Millennium Edition Platform Note: The name of the executable file includes the path. Long file names (non-8dot3 names) can be shortened to their 8dot3 representation.

The following code example displays its own command line.

// Sample for the Environment::CommandLine property.
using namespace System;
int main()
{
   Console::WriteLine();
   
   //  Invoke this sample with an arbitrary set of command line arguments.
   Console::WriteLine( "CommandLine: {0}", Environment::CommandLine );
}

/*
This example produces the following results:

C:\>env0 ARBITRARY TEXT

CommandLine: env0 ARBITRARY TEXT
*/

// Sample for the Environment.CommandLine property.
import System.*;

class Sample
{
    public static void main(String[] args)
    {
        Console.WriteLine();
        //  Invoke this sample with an arbitrary set of command line arguments.
        Console.WriteLine("CommandLine: {0}", Environment.get_CommandLine());
    } //main
} //Sample
/*
This example produces the following results:

C:\>env0 ARBITRARY TEXT

CommandLine: env0 ARBITRARY TEXT
*/

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft