Questions tagged [cmd]

Command Prompt (executable name cmd.exe) is the Microsoft supplied command line interpreter on OS/2, Windows CE, and all Microsoft Windows operating systems. Use this tag for questions regarding programming scripts or on commands available to run from the Command Prompt. Add tags for which version of Windows, and tags describing the task or issue.

Command Prompt (executable name cmd.exe) is the Microsoft-supplied command-line interpreter on Windows NT-based operating systems (including Windows 2000, XP, Vista, 7, 8, 10, Server 2003, Server 2008, Server 2012 and Server 2016), OS/2 and Windows CE. It is the analog of COMMAND.COM in MS-DOS and Windows 9x (where it is called MS-DOS Prompt) systems, or of the Unix shells used on Unix-like systems.

Include additional tags to identify the version of Windows such as , , , etc.

Resources:

See also:

26386 questions
1311
votes
23 answers

How do I run two commands in one line in Windows CMD?

I want to run two commands in a Windows CMD console. In Linux I would do it like this touch thisfile ; ls -lstrh How is it done on Windows?
flybywire
  • 261,858
  • 191
  • 397
  • 503
1288
votes
28 answers

How do I remove the process currently using a port on localhost in Windows?

How can I remove the current process/application which is already assigned to a port? For example: localhost:8080
KavinduWije
  • 39,451
  • 4
  • 14
  • 17
1121
votes
12 answers

How to "comment-out" (add comment) in a batch/cmd?

I have a batch file that runs several python scripts that do table modifications. I want to have users comment out the 1-2 python scripts that they don't want to run, rather than removing them from the batch file (so the next user knows these…
user1397044
  • 11,679
  • 6
  • 19
  • 16
969
votes
7 answers

How do I get the application exit code from a Windows command line?

I am running a program and want to see what its return code is (since it returns different codes based on different errors). I know in Bash I can do this by running echo $? What do I do when using cmd.exe on Windows?
Skrud
  • 11,604
  • 5
  • 24
  • 22
880
votes
12 answers

Windows batch files: .bat vs .cmd?

As I understand it, .bat is the old 16-bit naming convention, and .cmd is for 32-bit Windows, i.e., starting with NT. But I continue to see .bat files everywhere, and they seem to work exactly the same using either suffix. Assuming that my code will…
Chris Noe
  • 36,411
  • 22
  • 71
  • 92
852
votes
18 answers

How to run multiple .BAT files within a .BAT file

I'm trying to get my commit-build.bat to execute other .BAT files as part of our build process. Content of commit-build.bat: "msbuild.bat" "unit-tests.bat" "deploy.bat" This seems simple enough, but commit-build.bat only executes the first item in…
Th3Fix3r
828
votes
7 answers

How to redirect Windows cmd stdout and stderr to a single file?

I'm trying to redirect all output (stdout + stderr) of a Windows command to a single file: C:\>dir 1> a.txt 2> a.txt The process cannot access the file because it is being used by another process. Is it possible, or should I just redirect to two…
ripper234
  • 222,824
  • 274
  • 634
  • 905
746
votes
25 answers

Batch file to delete files older than N days

I am looking for a way to delete all files older than 7 days in a batch file. I've searched around the web, and found some examples with hundreds of lines of code, and others that required installing extra command line utilities to accomplish the…
Kibbee
  • 65,369
  • 27
  • 142
  • 182
745
votes
15 answers

How to use ADB Shell when Multiple Devices are connected? Fails with "error: more than one device and emulator"

$ adb --help -s SERIAL use device with given serial (overrides $ANDROID_SERIAL) $ adb devices List of devices attached emulator-5554 device 7f1c864e device $ adb shell -s 7f1c864e error: more than one device and emulator
Jackie
  • 21,969
  • 32
  • 147
  • 289
685
votes
24 answers

"rm -rf" equivalent for Windows?

I need a way to recursively delete a folder and its children. Is there a prebuilt tool for this, or do I need to write one? DEL /S doesn't delete directories. DELTREE was removed from Windows 2000+
FlySwat
  • 172,459
  • 74
  • 246
  • 311
664
votes
29 answers

Is there a command to refresh environment variables from the command prompt in Windows?

If I modify or add an environment variable I have to restart the command prompt. Is there a command I could execute that would do this without restarting CMD?
Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
653
votes
14 answers

Install an apk file from command prompt?

I want to install a file using the Windows command line. First I want to build after compiling all the .jar files to create an .apk file for an Android application without using Eclipse. Does anyone know how this can be done without the use of…
Max
  • 7,003
  • 4
  • 19
  • 17
641
votes
34 answers

How do I measure execution time of a command on the Windows command line?

Is there a built-in way to measure execution time of a command on the Windows command line?
Kuroki Kaze
  • 8,161
  • 4
  • 36
  • 48
628
votes
30 answers

How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?

Update: Now that it's 2016 I'd use PowerShell for this unless there's a really compelling backwards-compatible reason for it, particularly because of the regional settings issue with using date. See @npocmaka's…
Rory
  • 40,559
  • 52
  • 175
  • 261
616
votes
13 answers

How can I extract audio from video with ffmpeg?

I tried the following command to extract audio from video: ffmpeg -i Sample.avi -vn -ar 44100 -ac 2 -ab 192k -f mp3 Sample.mp3 but I get the following output libavutil 50.15. 1 / 50.15. 1 libavcodec 52.72. 2 / 52.72. 2 libavformat 52.64. 2…
user1269669
  • 6,177
  • 3
  • 14
  • 5
1
2 3
99 100