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
616
votes
35 answers

How can I create an empty file at the command line in Windows?

How can I create an empty file at the DOS/Windows command-line? I tried: copy nul > file.txt But it always displays that a file was copied. Is there another method in the standard cmd? It should be a method that does not require the touch command…
Grendler
  • 6,327
  • 3
  • 16
  • 8
593
votes
4 answers

Defining and using a variable in batch file

I'm trying to define and use a variable in a batch file. It looks like it should be simple: @echo off set location = "bob" echo We're working with "%location%" The output I get is the following: We're working with "" What's going on here? Why is…
Jamie Dixon
  • 53,019
  • 19
  • 125
  • 162
585
votes
13 answers

Create folder with batch but only if it doesn't already exist

Can anybody tell me how to do the following in in a Windows batch script? (*.bat): Create a folder only if it doesn't already exist In more detail, I want to create a folder named VTS on the C:\ drive, but only if that folder doesn't already…
Bill
  • 5,851
  • 2
  • 15
  • 3
516
votes
14 answers

Command prompt won't change directory to another drive

I'm trying to compile some java (learning java currently), and to do so I need to change command-prompt's directory. C:\...\Admin> cd D:\Docs\Java C:\...\Admin> cd C:\...\Admin It doesn't change the directory. I try again using…
nebuch
  • 6,475
  • 4
  • 20
  • 39
486
votes
12 answers

Windows equivalent to UNIX pwd

How do I find the local path on Windows in a command prompt?
Joshua
  • 26,234
  • 22
  • 77
  • 106
446
votes
32 answers

Displaying Windows command prompt output and redirecting it to a file

How can I run a command-line application in the Windows command prompt and have the output both displayed and redirected to a file at the same time? If, for example, I were to run the command dir > test.txt, this would redirect output to a file…
Ammu
440
votes
17 answers

Iterate all files in a directory using a 'for' loop

How can I iterate over each file in a directory using a for loop? And how could I tell if a certain entry is a directory or if it's just a file?
Vhaerun
  • 12,806
  • 16
  • 39
  • 38
439
votes
30 answers

I want to delete all bin and obj folders to force all projects to rebuild everything

I work with multiple projects, and I want to recursively delete all folders with the name 'bin' or 'obj' that way I am sure that all projects will rebuild everything (sometimes it's the only way to force Visual Studio to forget all about previous…
MichaelD
  • 8,377
  • 10
  • 42
  • 47
437
votes
41 answers

How can I open a cmd window in a specific location?

How can I open a cmd window in a specific location without having to navigate all the way to the directory I want?
Haim Bender
  • 7,937
  • 10
  • 53
  • 55
390
votes
16 answers

How to delete files/subfolders in a specific directory at the command prompt in Windows

Say, there is a variable called %pathtofolder%, as it makes it clear it is a full path of a folder. I want to delete every single file and subfolder in this directory, but not the directory itself. But, there might be an error like 'this file/folder…
Deniz Zoeteman
  • 9,691
  • 26
  • 70
  • 97
385
votes
12 answers

Change the default terminal in Visual Studio Code

I am using Visual Studio Code on my Windows 10 PC. I want to change my default terminal from Windows PowerShell to Bash on Ubuntu (on Windows). How can I do that?
abhijeetps
  • 4,609
  • 4
  • 17
  • 30
374
votes
14 answers

How do I display a text file content in CMD?

I want to display the content of a text file in a CMD window. In addition, I want to see the new lines that added to file, like tail -f command in Unix.
Refael
  • 6,753
  • 9
  • 35
  • 54
361
votes
12 answers

Assign output of a program to a variable using a MS batch file

I need to assign the output of a program to a variable using a MS batch file. So in GNU Bash shell I would use VAR=$(application arg0 arg1). I need a similar behavior in Windows using a batch file. Something like set VAR=application arg0…
initialZero
  • 6,197
  • 9
  • 29
  • 38
356
votes
13 answers

What is the Windows equivalent of the diff command?

I know that there is a post similar to this : here. I tried using the comp command like it mentioned, but if I have two files, one with data like "abcd" and the other with data "abcde", it just says the files are of different sizes. I wanted to know…
wittythotha
  • 3,956
  • 4
  • 19
  • 18
354
votes
13 answers

What is the alternative for ~ (user's home directory) on Windows command prompt?

I'm trying to use the command prompt to move some files, I am used to the linux terminal where I use ~ to specify the my home directory I've looked everywhere but I couldn't seem to find it for windows command prompt (Documents and Settings\[user])
fenerlitk
  • 5,414
  • 9
  • 29
  • 39