Search found 122 matches

by jfl
25 Jan 2019 11:39
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 4380

Re: Directly reading from pipe by the parent CMD process

Here's an updated version of my :CreatePipe test script, with the following changes: Added an argument to :CreatePipe to avoid using a global variable for known handles. Rewrote :EnumHandles for better reliability. For explanations, see this post . Added several new testing options, and a help scree...
by jfl
24 Jan 2019 16:24
Forum: DOS Batch Forum
Topic: How to enumerate used and free file handles
Replies: 3
Views: 944

Re: How to enumerate used and free file handles

Aacini wrote:
24 Jan 2019 14:05
I enjoyed your description a lot! :D
...
Thank :D
by jfl
24 Jan 2019 12:45
Forum: DOS Batch Forum
Topic: How to enumerate used and free file handles
Replies: 3
Views: 944

How to enumerate used and free file handles

This post is to summarize the findings in thread foolproof counting of arguments , where this was a side issue, and add my own findings while using them for the :CreatePipe routine. The command interpreter gives access to 10 handles, numbered 0 to 9. The first three always exist: Handle 0 is standar...
by jfl
22 Jan 2019 17:50
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 4380

Re: Directly reading from pipe by the parent CMD process

Found it, starting at the bottom of the first post at - https://www.dostips.com/forum/viewtopic.php?f=3&t=2836&hilit=handle&start=45#p57866 Thanks Dave for the link! With it, I've been able to fully resolve the problem, and write a resilient :CreatePipe, that adapts to ANY previous combination of o...
by jfl
22 Jan 2019 05:04
Forum: DOS Batch Forum
Topic: Making a batch file run faster
Replies: 1
Views: 665

Re: Making a batch file run faster

If all your files are numbered sequentially, like they seem to be, then you simply need to use a (for /l) loop. For example something like: setlocal EnableExtensions EnableDelayedExpansion for /l %%n in (1,1,400000) do ( set "N=00000%%n" &:# Make sure there are at least 6 digits set "N=!N:~-6!" &:# ...
by jfl
22 Jan 2019 04:43
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 4380

Re: Directly reading from pipe by the parent CMD process

And here's an improved version that can create multiple pipes: @echo off :# Rerun self in a sub-shell, to avoid breaking the original shell file handles echo %0 | findstr :: >nul || (cmd /d /c ^""%~dp0\::\..\%~nx0" %*^" & exit /b) goto :start :# Pipe creation routine. Assumes all allocated handles a...
by jfl
22 Jan 2019 03:48
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 4380

Re: Directly reading from pipe by the parent CMD process

I found doskey.exe (19 KB) print anything and is lightweight than cmd.exe (268 KB) Other option can be rundll32.exe (68 KB) Good ideas! I tested the three versions on 1000 loops creating pipes, and got these results on my laptop: cmd /c break: 25 ms doskey: 23 ms rundll32: 21 ms The difference is s...
by jfl
08 Jan 2019 03:58
Forum: DOS Batch Forum
Topic: save playlist as unicode or ?
Replies: 7
Views: 1485

Re: save playlist as unicode or ?

How do I figure out which code page windows explorer is using ? Windows Explorer is using UTF-16 LE always. Now, to find out which is the default 8-bit code page for non-Unicode Windows apps in your localized version of Windows, aka. the "System Code Page", you need to look in the registry value AC...
by jfl
05 Jan 2019 15:16
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 4380

Re: Directly reading from pipe by the parent CMD process

Hi, I found the solution, and it's surprisingly simple. This allows to write a reusable :CreatePipe routine: @echo off :# Rerun self in a sub-shell, to avoid breaking the original shell file handles echo %0 | findstr :: >nul || (cmd /d /c ^""%~dp0\::\..\%~nx0" %*^" & exit /b) goto :start :# Pipe cre...
by jfl
02 Jan 2019 13:09
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 4380

Re: Directly reading from pipe by the parent CMD process

Thanks @sst, that's a really great trick!!! Like @dbenham, it took me a long time to understand it. The critical point is a bug in cmd.exe, which undoes multiple redirections in the same order it created them, instead of the inverse order as it should. So by using TWO redirections that step on each ...
by jfl
07 Dec 2018 08:27
Forum: DOS Batch Forum
Topic: A new tool to save and restore the console font
Replies: 4
Views: 1791

A new tool to save and restore the console font

Hello, Earlier this week, I've been hit by a problem with the console font unexpectedly changing when I ran a new batch script on one of my test systems. I quickly found the root cause, which was another PowerShell script called from a batch script. Surprisingly, the PowerShell script was innocent. ...
by jfl
22 May 2018 09:59
Forum: DOS Batch Forum
Topic: How do i return a string from cpp program to caller batch file?
Replies: 8
Views: 1981

Re: How do i return a string from cpp program to caller batch file?

Sorry, I read the question too fast.

If you have a pointer to the injection method you mention, I'm interested: I got several requests in the past for setting shell environment variables!
And (for old timers) this used to be feasible easily in MS-DOS' command.com.
by jfl
22 May 2018 03:52
Forum: DOS Batch Forum
Topic: How to debug BATCH files
Replies: 5
Views: 1440

Re: How to debug BATCH files

You're right, this is a bug.
I'll fix that eventually as you suggest.
(Or better still, you can submit a pull request :-)
by jfl
21 May 2018 14:20
Forum: DOS Batch Forum
Topic: How to debug BATCH files
Replies: 5
Views: 1440

Re: How to debug BATCH files

I've posted a powerful batch debugging library there: https://github.com/JFLarvoire/SysToolsLib/blob/master/Batch/Library.bat You can find some high level documentation in the html file there: https://github.com/JFLarvoire/SysToolsLib/blob/master/Docs/System%20Script%20Libraries%20Description.htm Th...
by jfl
21 May 2018 13:25
Forum: DOS Batch Forum
Topic: strange file names
Replies: 4
Views: 1546

Re: strange file names

Assuming everything was done at the command prompt... The question marks likely mean that the code page and/or the font that you're using in the console do not contain the characters present in these files names. Try changing to the UTF-8 code page: (Which contains ALL Unicode characters) chcp 65001...