All Questions

44
votes
8answers
64223 views

Arrays, linked lists and other data structures in cmd.exe (batch) script

I was playing with cmd.exe, but in its help I didn't find any info, how to define arrays. I have found, how to define simple variables: set a = 10 echo %a% But, I want to create arrays, linked lis...
101
votes
6answers
47137 views

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 ...
159
votes
6answers
103601 views

What are the undocumented features and limitations of the Windows FINDSTR command?

The Windows FINDSTR command is horribly documented. There is very basic command line help available through FINDSTR /?, or HELP FINDSTR, but it is woefully inadequate. There is a wee bit more document...
5
votes
2answers
1993 views

Why is no string output with 'echo %var%' after using 'set var = text' on command line?

I set a variable in CMD on Windows 8.1 with the set command, and tried to echo it. Here is an example: C:\Users\Logan>set var = text C:\Users\Logan>set var var = text C:\Users\Logan>e...
562
votes
23answers
939525 views

Batch file to delete files older than N days

I am looking for a way to delete all files older than 7 days in an MS-DOS batch file. I've searched around the web, and found some examples with hundreds of lines of code, and others that required in...
58
votes
13answers
100553 views

How to have multiple colors in a Windows batch file?

I was wondering if its possible to have different colored text on the same line in a Windows batch file, for example if it says echo hi world I want "hi" to be one color, and "world" to be another ...
10
votes
1answers
15786 views

Single line with multiple commands using Windows batch file

I try to understand how multiple commands in a single command line in a batch file work. dir & md folder1 & rename folder1 mainfolder And other case with similar commands, but & substit...
846
votes
13answers
1385894 views

How do I pass command line parameters to a batch file?

I need to pass id and password to a cmd (or bat) file at the time of running rather than hardcoding them into the file. Here's what the command line looks like: test.cmd admin P@55w0rd > test-log...
598
votes
6answers
537116 views

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 us...
756
votes
7answers
614799 views

What does %~dp0 mean, and how does it work?

I find %~dp0 very useful, and I use it a lot to make my batch files more portable. But the label itself seems very cryptic to me... what is the ~ doing? does dp mean drive and path? does the 0 refer...

Previous Next