What does cmd /C mean? [closed]
Asked Answered
O

3

295

I can understand cmd but not cmd /c. I was trying to invoke a java program from the current for which I use Runtime.getRuntime().exec("cmd /C java helloworld"); There arises my doubt.

Oversize answered 5/2, 2009 at 10:24 Comment(3)
To Moderators, is there a provision to move this to appropriate portal/subsidiary of stack overflow. That way this item will not be closed and users will be able to contribute more? I guess this should go to something similar to super user?Loosejointed
I find it a perfectly valid question for SO.Lapland
Start CMD in a directory: `CMD /k cd /D C:\` (where C:\ is the desired path)Puke
N
338

The part you should be interested in is the /? part, which should solve most other questions you have with the tool.

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.
Nonsense answered 5/2, 2009 at 10:44 Comment(6)
there's also a command to "pause" the cmd window after output: "cmd /c file_name & PAUSE" it is bit different from cmd /kPerfectible
what if a given command is kind of a server that starts it's own loop? should we use /C or /K?Extrusion
While executing command in C# via 'Process' is using /C mandatory in Windows 7 or Windows Server 2008 R2 operating system?Tva
I came here becasue its not behaving as described. Im runnig from git bash and cmd /c "dir" or any command will just leave me in cmd prompt without executing the ocmmand.Cumbrous
cmd /? | more ...to page the command switchesAntaeus
To start CMD in a specific path, use: `CMD /k cd /D C:\` (where C:\ is the desired path)Puke
W
136

/C Carries out the command specified by the string and then terminates.

You can get all the cmd command line switches by typing cmd /?.

Widespread answered 5/2, 2009 at 10:26 Comment(2)
But why would one want to? Why not just call the command directly, like "java helloworld"Medieval
because you might not be in CMD but you just wan to use cmd to execute a command for you. eg I am running a bash script and want it to execute a command that cmd can do but bash can not.Cumbrous
A
30
CMD.exe

Start a new CMD shell

Syntax
      CMD [charset] [options] [My_Command] 

Options       

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

From the help.

Alexandros answered 5/2, 2009 at 10:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.