Search found 110 matches

by jfl
05 Oct 2019 14:18
Forum: DOS Batch Forum
Topic: Automatically escaping strings to survive multiple parsings
Replies: 3
Views: 1430

Re: Automatically escaping strings to survive multiple parsings

You're right, I had not thought about recursive cases like this where different part of the command string are parsed different number of times. Indeed it's necessary to invoke my routines multiple times, with growing strings: C:\JFL\Temp>Library.bat -te "echo a&echo b" off _INITIAL=echo a&echo b # ...
by jfl
05 Oct 2019 11:06
Forum: DOS Batch Forum
Topic: Automatically escaping strings to survive multiple parsings
Replies: 3
Views: 1430

Automatically escaping strings to survive multiple parsings

There are many cases where batch strings are parsed multiple times before being used. For example when you build a command line from multiple parts, or pass arguments to a subroutine. Each time it's tricky if the command or arguments contain special characters like ^ & | ! etc... In that case, it's ...
by jfl
02 Oct 2019 03:00
Forum: DOS Batch Forum
Topic: Enabling the internal debug outputs of cmd.exe
Replies: 17
Views: 8691

Re: Enabling the internal debug outputs of cmd.exe

This seems highly dependent on the Windows 10 version:

In version 10.0.14393, this works, but the cmd shell hangs in the end.

In version 10.0.18362, this does not work (ie. there's no debug output, only the echo %%1 output), but the cmd shell silently exits.
by jfl
02 Oct 2019 02:36
Forum: DOS Batch Forum
Topic: Simple Batch Code to Detect Empty Sub-folder
Replies: 4
Views: 1559

Re: Simple Batch Code to Detect Empty Sub-folder

OK, I was showing the principle, not the exact code you need. In your case, that would be: dir /b "C:\TIER1\TIER2" | findstr /r . >NUL 2>NUL if errorlevel 1 ( rem The C:\TIER1\TIER2 directory is empty echo There were no files or folders to be deleted. ) else ( rem The C:\TIER1\TIER2 directory contai...
by jfl
01 Oct 2019 07:49
Forum: DOS Batch Forum
Topic: non-buffering FOR /F alternative
Replies: 7
Views: 2284

Re: non-buffering FOR /F alternative

Hi Steffen Your DirEvents.exe tool is impressively small, and it works nicely, except for one detail: How do you stop it? I tried Enter, ESC, Ctrl-C, and many other key combinations, without success. And I could not find any clue in the source. Eventually I had to kill it in Task Manager, which is n...
by jfl
01 Oct 2019 06:45
Forum: DOS Batch Forum
Topic: Some tricks with undefined variables
Replies: 3
Views: 2008

Re: Some tricks with undefined variables

Thanks jeb for these nice tricks! The first one really baffled me :shock: Five years ago, I thought I knew everything about batch, and I keep learning new tricks here! :D About trick 3): It's worth defining a macro for easy reuse: @echo off setlocal DisableDelayedExpansion set ECHO!=FOR /F "tokens=1...
by jfl
01 Oct 2019 04:47
Forum: DOS Batch Forum
Topic: powershell to bat
Replies: 1
Views: 1375

Re: powershell to bat

Use PowerShell's get-service to get the correspondence between the one-word service name used by the net.exe and sc.exe commands, and the more descriptive name used by PowerShell service management commands. Then simply use 'net start NAME' or 'net stop NAME' in your batch to start or stop the servi...
by jfl
01 Oct 2019 04:06
Forum: DOS Batch Forum
Topic: Simple Batch Code to Detect Empty Sub-folder
Replies: 4
Views: 1559

Re: Simple Batch Code to Detect Empty Sub-folder

I first tried 'if not exist subdir\* echo empty', but this does not work :-( So the solution is to list the sub-folder contents, and check for the presence of anything using 'findstr /r .'. The result is in findstr's %ERRORLEVEL%. Ex: C:\JFL\Temp\test>md Empty C:\JFL\Temp\test>md HasFile C:\JFL\Temp...
by jfl
01 Oct 2019 02:40
Forum: DOS Batch Forum
Topic: Thoughts on this alternative method of obtaining cmdcmdline arguments (safe for all characters?)
Replies: 14
Views: 2632

Re: Thoughts on this alternative method of obtaining cmdcmdline arguments (safe for all characters?)

Getting 500 server error messages each time I either edit or submit a post. Anyone else getting these? Tried to edit the OP twice subsequent to the first edit and it failed. Yes, I got these as well when I tried posting a message about my updated version of which.exe last week. I retried several ti...
by jfl
26 Sep 2019 05:45
Forum: DOS Batch Forum
Topic: which.exe - The best of Windows where.exe and Unix which, and some more
Replies: 5
Views: 2491

Re: which.exe - The best of Windows where.exe and Unix which, and some more

Here's version 1.14 of my which.exe program for DOS and Windows: http://jf.larvoire.free.fr/progs/which_v1.14.zip Note that this zip file contains multiple versions of which.exe: The one at the root, which runs in all Microsoft OSs, as explained in the opening post ; And several stripped down versio...
by jfl
28 Jul 2019 09:53
Forum: DOS Batch Forum
Topic: self-compiled .net hybrids
Replies: 24
Views: 17340

Re: self-compiled .net hybrids

One small improvement to the batch initialization: During the JS development phase, it's necessary to recompile the source script every time it's updated. The following code automates that: @echo off setlocal set "jsc=" for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*jsc.exe") do set "jsc=%...
by jfl
07 May 2019 07:50
Forum: DOS Batch Forum
Topic: A new tool to save and restore the console font
Replies: 4
Views: 1337

Re: A new tool to save and restore the console font

font.exe version 2.1.1 is now available on https://github.com/JFLarvoire/SysToolsLib/releases, with the following changes:
  • Fixed the TrueType fonts setting, which sometimes ended up looking blurry.
  • Added an optional font weight argument.
Run 'font -?' to get a help screen.
by jfl
11 Apr 2019 06:24
Forum: DOS Batch Forum
Topic: Command only listing active NIC?
Replies: 2
Views: 620

Re: Command only listing active NIC?

I have a script that does just that: ipcfg.bat , part of my System Tools Library ipcfg.bat has lots of options. But the idea is to select only "interesting" network information. By default, it outputs just the information for the active NICs, as you're trying to do. Examples: C:\JFL\Temp>ipcfg -l Et...
by jfl
04 Apr 2019 03:00
Forum: DOS Batch Forum
Topic: Ipconfig doesn't work inside a bat file
Replies: 18
Views: 2581

Re: Ipconfig doesn't work inside a bat file

None of the Microsoft ping programs (ping, pathping, psping) output: Enter the ping options: I tried that on several of my systems, with various Windows versions, and indeed none of them contain that string. Ex: C:\JFL\Temp>strings C:\Windows\System32\ping.exe | findstr /i please C:\JFL\Temp>string...
by jfl
02 Apr 2019 09:44
Forum: DOS Batch Forum
Topic: which.exe - The best of Windows where.exe and Unix which, and some more
Replies: 5
Views: 2491

Re: which.exe v1.12 - Now efficiently detecting doskey macros and PS aliases

That's a neat tool, I like it :) Thanks! I have a question as to how option -a is intended to work. If I run 'which -a cmd.exe' I was expecting that more than one file was found on my Win10 x64. Also if I run it in the WOW64 subsystem, it reports that cmd.exe was found in System32, which isn't wron...