Search found 86 matches

by dbenham
29 Apr 2020 22:24
Forum: DOS Batch Forum
Topic: Weird behavior of ~f modifier when path includes wildcards
Replies: 2
Views: 1550

Weird behavior of ~f modifier when path includes wildcards

I've long known that the ~f modifier used with parameter or FOR variable expansion is able to expand paths with wildcards into the first folder/file that it finds. The ~f modifier treats each node with wildcards within the source path separately when expanding wildcards, and works from left to right...
by dbenham
19 Mar 2020 21:26
Forum: DOS Batch Forum
Topic: 8191 buffer limit: Different Windows 10 builds behave differently
Replies: 5
Views: 2192

8191 buffer limit: Different Windows 10 builds behave differently

The 8191 character size limit is pervasive throughout cmd.exe batch parsing. There are many buffers in the various phases, each one limited to 8191 bytes. I wanted to investigate how each "phase" handles an overflow of the buffer. I know sometimes it creates an error, sometimes the data is truncated...
by dbenham
09 Feb 2020 16:04
Forum: DOS Batch Forum
Topic: Surprising difference between command line and batch
Replies: 7
Views: 5745

Surprising difference between command line and batch

I was messing around with escaped token delimiters, and I discovered a difference between command line and batch contexts. A batch script allows you to execute a command with escaped spaces (or any token delimiter) within the name. Note that a name cannot be called with escapes directly because CALL...
by dbenham
29 Jan 2020 15:16
Forum: DOS Batch Forum
Topic: Erroneous GOTO does not break FOR loops
Replies: 2
Views: 2354

Erroneous GOTO does not break FOR loops

This post is about the erroneous GOTO technique used to exit from a CALL but allow concatenated commands to execute in the context of the CALLer. It was first described in DosTips at Tricky way to detect calls from another batch script . It has been very useful. For example, it enabled creation of a...
by dbenham
08 Jan 2020 16:03
Forum: DOS Batch Forum
Topic: cmd.exe chars needing quotes, and escaping redirection handles
Replies: 6
Views: 2105

cmd.exe chars needing quotes, and escaping redirection handles

Below are some newly discovered cmd.exe facts (at least for me) that likely no one cares about 1) Special characters listed in cmd help The following statement at the end of the cmd help (HELP CMD or CMD /?) used to really irk me. The special characters that require quotes are: <space> &()[]{}^=;!'+...
by dbenham
15 Aug 2019 12:20
Forum: DOS Batch Forum
Topic: Newly discovered pipe behavior - and a fun challenge!
Replies: 5
Views: 5044

Newly discovered pipe behavior - and a fun challenge!

Over at https://stackoverflow.com/a/57492041/1012053 jeb deduced a newly discovered behavior of Windows pipes. We had all thought that each side of a pipe is always executed in a new cmd.exe process via CMD /S /D /C. Well it turns out cmd.exe is only used if the command is an internal command, or if...
by dbenham
30 May 2019 23:07
Forum: DOS Batch Forum
Topic: Safely parse nearly any CSV with pure batch
Replies: 1
Views: 2711

Safely parse nearly any CSV with pure batch

Quite some time ago I developed a hybrid JScript/batch parseCSV.bat utility to assist with parsing CSV files with FOR /F. It could handle any CSV as long as you didn't need to parse more than 32 tokens, and no line approached 8191 bytes. Much later, Aacini started a thread where routines were develo...
by dbenham
15 May 2019 10:57
Forum: DOS Batch Forum
Topic: Enable ANSI escape sequence within Windows 10 console
Replies: 7
Views: 5443

Enable ANSI escape sequence within Windows 10 console

Starting with Windows 10, the console supports ANSI escape sequences, but only if the console is configured to NOT "use legacy console", and the program writing to the console must configure its output to interpret the sequences. CMD.EXE was modified such that its internal commands do support the AN...
by dbenham
04 May 2019 22:37
Forum: DOS Batch Forum
Topic: Successfully escape a token delimiter in a fully qualified command path!
Replies: 7
Views: 3971

Successfully escape a token delimiter in a fully qualified command path!

I had always understood that you cannot escape token delimiters - only quotes will work. I suppose I knew that the token delimiter is initially escaped in phase 2 , but in a subsequent phase (execution phase 7, possibly others) the token delimiter cannot be escaped. So even if you escape a space in ...
by dbenham
04 Sep 2018 13:46
Forum: DOS Batch Forum
Topic: HEXDUMP.BAT version 2.1 using CERTUTIL
Replies: 1
Views: 2147

HEXDUMP.BAT version 2.1 using CERTUTIL

Over 7 years ago I wrote a pure batch HEXDUMP.BAT script (and function) that could read a binary file and write out a nicely formatted hex dump of the content. That script relied on a clever FC technique to read the data. It works great, but is very slow. Now that we have a bunch of options for CERT...
by dbenham
25 Jan 2018 14:43
Forum: DOS Batch Forum
Topic: Discussion about jeb's batch parsing rules on StackOverflow
Replies: 42
Views: 17011

Discussion about jeb's batch parsing rules on StackOverflow

The purpose of this thread is to have a central place to discuss the batch parsing rules on StackOverflow that jeb initiated. Of particular interest are discussions about shortcomings or inaccuracies of the current model, along with suggestions for improvements. I've already made a great many change...
by dbenham
23 Oct 2017 12:23
Forum: DOS Batch Forum
Topic: Closing parenthesis prevents escape of subsequent special character operator
Replies: 33
Views: 18650

Closing parenthesis prevents escape of subsequent special character operator

I am not able to escape a special character operator token if it appears immediately after a closing parenthesis. Not sure how this is useful, but I find it interesting. I would expect the escaped forms to generate a syntax error, but rather the "escaped" operator is fully functional Anyon...
by dbenham
27 Sep 2017 21:34
Forum: DOS Batch Forum
Topic: JREPL.BAT, ADO Streams and big files
Replies: 7
Views: 2318

JREPL.BAT, ADO Streams and big files

This discussion is a continuation of a topic that was started here , that became tangential to the CONVERTCP topic. On the other hand the main scopes of JREPL and CONVERTCP are quite different. This makes that JREPL is able (and designed) to do customized replacements while CONVERTCP can't do that....
by dbenham
02 Sep 2017 12:02
Forum: DOS Batch Forum
Topic: Exclude current directory from PATH search
Replies: 7
Views: 2342

Exclude current directory from PATH search

In a StachOverflow comment I saw the following fascinating bit of info: Starting with Windows Vista, you can remove the current directory from the implicit search path in CMD and CreateProcess by defining the environment variable NoDefaultCurrentDirectoryInExePath. I tested on my Win 10 machine, and...
by dbenham
05 Dec 2016 23:47
Forum: DOS Batch Forum
Topic: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like
Replies: 47
Views: 31387

HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

The Windows CERTUTIL command has an option to compute file hashes using any of the following algorithms: MD2, MD4, MD5, SHA1, SHA256, SHA384, SHA512. C:\test>certutil -hashfile test.bat md5 MD5 hash of file test.bat: 89 68 0c 14 1d 7a 1f 00 a2 43 79 c6 b1 ac fd b9 CertUtil: -hashfile command complet...