Search found 2111 matches

by dbenham
24 Sep 2018 10:17
Forum: DOS Batch Forum
Topic: FOR loop does not increment /L %%parameter
Replies: 13
Views: 155

Re: FOR loop does not increment /L %%parameter

I see 4 serious bugs that I annotated in your code below (see BUG comments): @Echo off call :searchUSBdriveLetters pause :: BUG-Falls into search routine. Need EXIT /B or GOTO :EOF to fix =% :searchUSBdriveLetters setlocal enabledelayedexpansion Set /a "i=0" For /f "tokens=1-9" %%a IN ( 'wmic logica...
by dbenham
19 Sep 2018 20:06
Forum: DOS Batch Forum
Topic: Why ~dpf ?
Replies: 9
Views: 468

Re: Why ~dpf ?

I have a vague recollection of seeing that question before years ago (I may have even asked), and no one had a reason for using %~dpf0.

There certainly is no logical reason for it, and I've never seen any odd behavior that would warrant it.


Dave Benham
by dbenham
18 Sep 2018 08:50
Forum: DOS Batch Forum
Topic: How to detect if input comes from pipe or redirected file
Replies: 9
Views: 2276

Re: How to detect if input comes from pipe or redirected file

First off, I don't like any method that reads from stdin or writes to stdout or stderr because I view that as destructive - the result of a script can change from what it was without any detection. But ignoring that concern... "#1 No redirection", "#3 stderr redirected", and "#4 both redirected" all...
by dbenham
17 Sep 2018 12:05
Forum: DOS Batch Forum
Topic: How to detect if input comes from pipe or redirected file
Replies: 9
Views: 2276

Re: How to detect if input comes from pipe or redirected file

Great idea :!: :idea: 8) I forgot about that TIMEOUT feature. I was always irritated by that design, but I never thought to apply the feature in this case. Very useful. TIMEOUT is not available to XP, but hopefully that should not be much of an issue. At long last I think that Win version is finally...
by dbenham
17 Sep 2018 09:08
Forum: DOS Batch Forum
Topic: How to detect if input comes from pipe or redirected file
Replies: 9
Views: 2276

Re: How to detect if input comes from pipe or redirected file

The technique in the original post is very fragile, to the point I would never rely on it. The redirected input test only works if there has not been any other redirection prior to redirecting the input. For example, the following falsely claims there is no redirected input or pipe: >nul <file.txt M...
by dbenham
08 Sep 2018 15:11
Forum: DOS Batch Forum
Topic: SNAKE.BAT 4.1 - An arcade style game using pure batch
Replies: 107
Views: 143655

Re: SNAKE.BAT 4.1 - An arcade style game using pure batch

I've posted version 4.1 with the bug fix to properly handle "Playfield too large" error in the first post of this thread.
by dbenham
08 Sep 2018 07:25
Forum: DOS Batch Forum
Topic: SNAKE.BAT 4.1 - An arcade style game using pure batch
Replies: 107
Views: 143655

Re: SNAKE.BAT 4.0 - An arcade style game using pure batch

"ERROR: Playfield area too large "quit" is an internal or external command, a program that can be executed, or This is not a batch file." help me how to fix it? The error message indicates that you are trying to run the game with play field dimensions that exceed the capabilities of the game. The o...
by dbenham
05 Sep 2018 18:19
Forum: DOS Batch Forum
Topic: Help can JREPL do this?
Replies: 10
Views: 164

Re: Help can JREPL do this?

The error is due to a ! within the regex search string and delayedExpansion. You start out with delayed expansion off, so JREPL works the first time. But after you run JREPL, you SETLOCAL EnableDelayedExpansion, but fail to ENDLOCAL before you loop back. (Actually you have 2 SETLOCAL, but only 1 END...
by dbenham
05 Sep 2018 08:16
Forum: DOS Batch Forum
Topic: HEXDUMP.BAT version 2.1 using CERTUTIL
Replies: 1
Views: 112

Re: HEXDUMP.BAT version 2.1 using CERTUTIL

I've updated the original post to version 2.1

The only change is some minor redesign of the exit process to ensure that temp files are "always" deleted, even if there is an error.


Dave Benham
by dbenham
05 Sep 2018 06:42
Forum: DOS Batch Forum
Topic: Help can JREPL do this?
Replies: 10
Views: 164

Re: Help can JREPL do this?

I should think you don't need (want) to preserve the "Window Title:" text at the beginning, as this is a constant. It is easy to remove it, and then you are guaranteed that all relevant lines have at least one change, so the /A option is safe to use. I also refined the /INC and /EXC options to be mo...
by dbenham
05 Sep 2018 06:30
Forum: DOS Batch Forum
Topic: Help can JREPL do this?
Replies: 10
Views: 164

Re: Help can JREPL do this?

Oops. Yes, I forgot about that requirement. Yes, you can use the negative look ahead feature to find the last dot. With this requirement it is easier to break the operation into 2 JREPL steps, saving the removal of leading and trailing spaces until the second step. tasklist /fi "imagename eq PotPlay...
by dbenham
05 Sep 2018 04:16
Forum: DOS Batch Forum
Topic: Help can JREPL do this?
Replies: 10
Views: 164

Re: Help can JREPL do this?

Untested, as I am not at a Windows machine, but I believe the following should work: call jrepl "^[. ]+|[. ]+$|\[[^\]]*\]#\." "# " /t # /f PotPlayerTitle.txt /o PotPlayerTitle.txt The above uses the /T option to do multiple find/replace in one pass, using # as the delimiter between expressions. ^[. ...
by dbenham
04 Sep 2018 13:55
Forum: DOS Batch Forum
Topic: more tricks with certutil
Replies: 9
Views: 685

Re: more tricks with certutil

I've posted a convenient HEXDUMP.BAT utility that utilizes these "new" CERTUTIL -encodeHex formatting options at viewtopic.php?f=3&t=8816


Dave Benham
by dbenham
04 Sep 2018 13:46
Forum: DOS Batch Forum
Topic: HEXDUMP.BAT version 2.1 using CERTUTIL
Replies: 1
Views: 112

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
03 Sep 2018 23:24
Forum: DOS Batch Forum
Topic: more tricks with certutil
Replies: 9
Views: 685

Re: more tricks with certutil

ShadowThief wrote:
03 Sep 2018 22:20
It's possible that your mileage may vary, but I don't know why it would.
Mine varied :twisted:

I tried to use encodehex instead of encode, and it failed well before 74 MB,