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
91
votes
3 answers

Echo %path% on separate lines

Using the Windows command prompt, can I echo %path% and get the resulting paths on separate rows? Something like this, but for Windows: echo $PATH | tr ':' '\n' Can I do this with vanilla cmd or do I need PowerShell or JavaScript scripting? Example…
Carl R
  • 8,104
  • 5
  • 48
  • 80
89
votes
8 answers

using batch echo with special characters

This maybe really easy but there were no answers for it over the net. I want to echo a XML line via batch into a file but it misunderstands the XML closing tag for redirection ">". The line is as follows: echo
Amir Zadeh
  • 3,481
  • 2
  • 26
  • 47
89
votes
3 answers

Find Process Name by its Process ID

Suppose I know the process ID. I want to find the process name by its ID, using windows batch script. How can I do this?
Oz Molaim
  • 2,016
  • 4
  • 20
  • 29
89
votes
14 answers

What is the easiest way to reset ERRORLEVEL to zero?

I have a post-build event that runs some commands for a c# project. The last command would sometimes cause the ERRORLEVEL value not equals to zero and then the build fails. I want to append an extra line of command to always set the ERRORLEVEL value…
user95319
  • 1,213
  • 1
  • 8
  • 12
88
votes
12 answers

How do you run a command as an administrator from the Windows command line?

I have a small script that performs the build and install process on Windows for a Bazaar repository I'm managing. I'm trying to run the script with elevated, administrative privileges from within the Windows shell (cmd.exe)--just as if I'd…
jpaugh
  • 6,634
  • 4
  • 38
  • 90
88
votes
11 answers

What ever happened to deltree, and what's its replacement?

In earlier versions of MS-DOS - I want to say version 7, but I could be wrong - there was a deltree command, which recursively deleted all subdirectories and files from a given path. deltree no longer exists, but del didn't seem to inherit the…
David Koelle
  • 20,726
  • 23
  • 93
  • 130
87
votes
6 answers

How do I get a list of folders and sub folders without the files?

I am trying to print a list of the folders and sub folders of a directory to a file. When I run dir /s/b/o:n > f.txt, I get a list of the files also. I only need the folders and sub folders. Anyone know is this possible to do this from command line…
Inkey
  • 2,189
  • 9
  • 39
  • 64
87
votes
4 answers

Unzip files (7-zip) via cmd command

I try to unzip a file via CMD. So I install winzip (and its plugin to cmd), winrar and 7-zip. But when I try to execute a command via the CMD: 7z e myzip.zip It gives the next error: 7z is not recognized as an internal or external command In…
Adam Sh
  • 8,137
  • 22
  • 60
  • 75
87
votes
6 answers

Out of a git console: how do I execute a batch file and then return to git console?

I have a small utility script called clear.bat that does some housekeeping work on my sources. It is a .bat file so that I could easily double-click it in Windows Explorer. Sometimes, I find it more handy to execute it from my Git bash (msysgit, if…
eckes
  • 64,417
  • 29
  • 168
  • 201
86
votes
19 answers

Windows command to convert Unix line endings?

Is there a Windows command to convert line endings of a file? We have a test.bat which we need to run to start our server. We use Perforce and we need to have unix line endings in our workspace. For some reason, we are not allowed to change line…
Deepti Jain
  • 1,901
  • 4
  • 21
  • 29
86
votes
4 answers

To "Call" or "Not to Call" a batch file?

If from inside a bat file you called another batch file but still had a few remaining operations to complete, how can you make sure that the call to first bat file will after completion or error, will return to the file that called it in the first…
AltF4_
  • 2,312
  • 5
  • 36
  • 56
84
votes
5 answers

openssl hangs and does not exit

I am trying to use openssl to get a certificate, and it seems to keep hanging. I have done a lot of research but not all of the available options seem to work on Windows. openssl s_client -showcerts -connect google.com:443 > cert.txt I have tried…
Adiboy
  • 843
  • 1
  • 6
  • 5
84
votes
5 answers

Echo off but messages are displayed

I turned off echo in bat file. @echo off then I do something like this ... echo %INSTALL_PATH% if exist %INSTALL_PATH%( echo 222 ... ) and I get: The system cannot find the path specified. message between those two echos. What can be the reason…
Aleksandr Kravets
  • 5,750
  • 7
  • 53
  • 72
84
votes
3 answers

What's the cmd/PowerShell equivalent of back tick on Bash?

Redirecting command output: For example: echo "Foo `./print_5_As.rb`" would echo "Foo AAAAA"
ramblinpeck
83
votes
4 answers

How can I escape an exclamation mark ! in cmd scripts?

When I have setlocal ENABLEDELAYEDEXPANSION set in a cmd script is there any way I can escape a ! that I want to use as a parameter to a command? @echo off setlocal ENABLEDELAYEDEXPANSION echo I want to go out with a bang! echo I still want to go…
Andy Morris
  • 3,393
  • 1
  • 21
  • 20