Freigeben über


Environment.CommandLine-Eigenschaft

Ruft die Befehlszeile für diesen Prozess ab.

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

Syntax

'Declaration
Public Shared ReadOnly Property CommandLine As String
'Usage
Dim value As String

value = Environment.CommandLine
public static string CommandLine { get; }
public:
static property String^ CommandLine {
    String^ get ();
}
/** @property */
public static String get_CommandLine ()
public static function get CommandLine () : String

Eigenschaftenwert

Eine Zeichenfolge mit den Befehlszeilenargumenten.

Hinweise

Diese Eigenschaft ermöglicht den Zugriff auf den Programmnamen und auf Argumente, die beim Start des Prozesses in der Befehlszeile angegeben wurden.

Der Programmname kann optional Pfadangaben enthalten. Verwenden Sie zum Abrufen der analysierten und in einem Zeichenfolgenarray gespeicherten Befehlszeileninformationen die GetCommandLineArgs-Methode.

Hinweis zu Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003: Der Name der ausführbaren Datei enthält keine Pfadangabe.

Hinweis zu Windows 98, Windows Millennium Edition: Der Name der ausführbaren Datei enthält eine Pfadangabe. Lange Dateinamen, die nicht im DOS-Format 8.3 vorliegen, können auf ihre 8.3-Darstellung verkürzt werden.

Beispiel

Im folgenden Codebeispiel wird eine eigene Befehlszeile angezeigt.

' Sample for the Environment.CommandLine property.
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      '  Invoke this sample with an arbitrary set of command line arguments.
      Console.WriteLine("CommandLine: {0}", Environment.CommandLine)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'C:\>CommandLine ARBITRARY TEXT
'
'CommandLine: CommandLine ARBITRARY TEXT
'
// Sample for the Environment.CommandLine property.
using System;

class Sample 
{
    public static void 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.
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
*/

.NET Framework-Sicherheit

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Environment-Klasse
Environment-Member
System-Namespace
GetCommandLineArgs