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
187
votes
14 answers

Delete files or folder recursively on Windows CMD

How do I delete files or folders recursively on Windows from the command line? I have found this solution where path we drive on the command line and run this command. I have given an example with a .svn file extension folder: for /r %R in (.svn) do…
modasser
  • 1,871
  • 2
  • 12
  • 3
183
votes
9 answers

How to unzip a file using the command line?

Which commands can be used via the command line to unzip a file? Preferably something built into Windows or open source/free tools.
Th3Fix3r
182
votes
8 answers

How does the Windows Command Interpreter (CMD.EXE) parse scripts?

I ran into ss64.com which provides good help regarding how to write batch scripts that the Windows Command Interpreter will run. However, I have been unable to find a good explanation of the grammar of batch scripts, how things expand or do not…
Benoit
  • 76,634
  • 23
  • 210
  • 236
175
votes
8 answers

How do I escape ampersands in batch files?

How do I escape ampersands in a batch file (or from the Windows command line) in order to use the start command to open web pages with ampersands in the URL? Double quotes will not work with start; this starts a new command-line window…
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
171
votes
9 answers

How to get folder path from file path with CMD

I need path to the folder that contains cmd file. With %0 I can get the file name. But how to get the folder name? c:\temp\test.cmd >> test.cmd P.S. My current directory != folder of the script.
Mike Chaliy
  • 25,801
  • 18
  • 67
  • 105
169
votes
5 answers

Set a persistent environment variable from cmd.exe

I have to set environment variables on different windows machines, but I don't want to be bothered changing them manually by getting on the properties screen of "My Computer" I want to do it from the command line, with a batch file. As far as I…
0x26res
  • 11,925
  • 11
  • 54
  • 108
169
votes
6 answers

relative path in BAT script

Here is my own program folder on my USB drive: Program\ run.bat bin\ config.ini Iris.exe library.dll etc. I would like to use run.bat to start Iris.exe I cannot use this: F:/Program/bin/Iris.exe like a…
user2083037
  • 1,691
  • 2
  • 11
  • 3
168
votes
5 answers

How to skip "are you sure Y/N" when deleting files in batch files

I can't for the life of me remember how to bypass the annoying prompt are you sure? Y/N when deleting files. I seem to recall it was something like: del C:\Test && ECHO Y
Michael Skelton
  • 2,005
  • 3
  • 15
  • 7
167
votes
8 answers

Check status of one port on remote host

I need a command line that can check the port status on a remote host. I tried ping xxx.xxx.xxx.xxx:161 but it doesn't recognize the "host". I thought it was a "good" answer until I did the same command against a host I know has that port open. …
Sheila
164
votes
17 answers

PHP is not recognized as an internal or external command in command prompt

I got the following error when I run a command with php C:\xampp\htdocs>php 'php' is not recognized as an internal or external command, operable program or batch file. I don't get any error when I run the command with php in following…
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
163
votes
17 answers

Delete all files and folders in a directory

I want to have a batch file that will delete all the folders and files in my cache folder for my wireless toolkit. Currently I have the following: cd "C:\Users\tbrollo\j2mewtk\2.5.2\appdb\RMS" del *.db This will delete all .db files in my RMS…
user69514
  • 26,935
  • 59
  • 154
  • 188
162
votes
6 answers

Can a Windows batch file determine its own file name?

Can a Windows batch file determine its own file name? For example, if I run the batch file C:\Temp\myScript.bat, is there a command within myScript.bat that can determine the string "myScript.bat"?
djangofan
  • 28,471
  • 61
  • 196
  • 289
158
votes
1 answer

How to redirect stderr to null in cmd.exe

I have an application that logs a lot of noise to stderr and REALLY slows down the execution of the application. I would like to redirect that output to null. Is this possible with cmd.exe?
Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
154
votes
12 answers

How do I echo and send console output to a file in a bat script?

I have a batch script that executes a task and sends the output to a text file. Is there a way to have the output show on the console window as well? For Example: c:\Windows>dir > windows-dir.txt Is there a way to have the output of dir display in…
JamesEggers
  • 12,885
  • 14
  • 59
  • 86
154
votes
12 answers

Removing double quotes from variables in batch file creates problems with CMD environment

Can anybody help with effective and safe way of removing quotes from batch variables? I have written a batch file which successfully imports a list of parameters %1, %2, %3 etc. and places them into named variables. Some of these parameters contain…
BobB
  • 1,587
  • 2
  • 11
  • 7