2009-02-05 4 views
145

kann ich cmd verstehen, aber nicht cmd /c. Ich habe versucht, ein Java-Programm aus dem Strom, für den ich Runtime.getRuntime().exec("cmd /C java helloworld"); verwenden, aufzurufen. Da entsteht mein Zweifel.Was bedeutet cmd/C?

Antwort

85

/C Führt den durch die Zeichenfolge angegebenen Befehl aus und wird dann beendet.

Sie können alle Cmd-Befehlszeilenoptionen durch Eingabe von cmd /? abrufen.

17
CMD.exe 

Start a new CMD shell 

Syntax 
     CMD [charset] [options] [My_Command] 

Options  

**/C  Carries out My_Command and then 
terminates** 

Von der Hilfe.

184

Der Teil, der Sie interessieren sollte, ist der /? Teil, der die meisten anderen Fragen lösen sollte, die Sie mit dem Werkzeug haben.

 
Microsoft Windows XP [Version 5.1.2600] 
(C) Copyright 1985-2001 Microsoft Corp. 

C:\>cmd /? 
Starts a new instance of the Windows XP command interpreter 

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF] 
    [[/S] [/C | /K] string] 

/C  Carries out the command specified by string and then terminates 
/K  Carries out the command specified by string but remains 
/S  Modifies the treatment of string after /C or /K (see below) 
/Q  Turns echo off 
/D  Disable execution of AutoRun commands from registry (see below) 
/A  Causes the output of internal commands to a pipe or file to be ANSI 
/U  Causes the output of internal commands to a pipe or file to be 
     Unicode 
/T:fg Sets the foreground/background colors (see COLOR /? for more info) 
/E:ON Enable command extensions (see below) 
/E:OFF Disable command extensions (see below) 
/F:ON Enable file and directory name completion characters (see below) 
/F:OFF Disable file and directory name completion characters (see below) 
/V:ON Enable delayed environment variable expansion using ! as the 
     delimiter. For example, /V:ON would allow !var! to expand the 
     variable var at execution time. The var syntax expands variables 
     at input time, which is quite a different thing when inside of a FOR 
     loop. 
/V:OFF Disable delayed environment expansion. 
+5

gibt es auch einen Befehl „Pause“ cmd Fenster nach der Ausgabe: „cmd/c file_name & Pause“ ist es etwas anders aus cmd/k – JerryGoyal

+0

was passiert, wenn ein bestimmte Befehl Art eines Servers ist, dass es beginnt eigene Schleife? sollen wir/C oder/K benutzen? –

+0

Während der Befehl in C# über 'Process' ausgeführt wird, ist/C in Windows 7 oder Windows Server 2008 R2 obligatorisch. –