Search found 12 matches

by jeb
2024-Mar-05, 1:01 pm
Forum: Windows CMD Shell
Topic: Puzzled by Delims
Replies: 4
Views: 432

Re: Puzzled by Delims

"delims=^=" is worse, as it defines two delim characters, a caret and an equal sign
by jeb
2024-Jan-13, 9:33 am
Forum: Windows CMD Shell
Topic: Shift command not working in wrapper script
Replies: 3
Views: 1370

Re: Shift command not working in wrapper script

The SHIFT command only move the numbered arguments %1,%2,...,%9, but has no effect on %* The solution of chatGPT works in this case, because the first argument seems to be a single word. But it's not a general solution, because it fails in the case where the first argument includes a space . myBatch...
by jeb
2023-Nov-10, 5:46 pm
Forum: Windows CMD Shell
Topic: The page: echo.html
Replies: 3
Views: 4443

Re: The page: echo.html

Thanks, but there is still a flaw on the page. There are some edge cases (such as adding \..\..\..\..\ to a variable) where only ( will work without errors e.g. Echo (%_var% There is a space between "ECHO" and "(", but there shouldn't. Better: ... where only "(" will wo...
by jeb
2023-Nov-10, 5:39 pm
Forum: Windows CMD Shell
Topic: the auto exec page
Replies: 7
Views: 15528

Re: the auto exec page

Hi Simon, the pipe behaves differently because when a pipe starts the sub processes it uses quite different options for cmd.exe test.bat @echo off setlocal EnableDelayedExpansion echo cmdcmdline=!cmdcmdline! C:\Users\jeb>echo Hello | test.bat cmdcmdline=C:\Windows\system32\cmd.exe /S /D /c" tes...
by jeb
2023-Nov-09, 9:02 am
Forum: Windows CMD Shell
Topic: the auto exec page
Replies: 7
Views: 15528

Re: the auto exec page

A short example Autorun.bat @echo off setlocal EnableDelayedExpansion set "cmd=!cmdcmdline!" if "%~1" NEQ "" goto :install if "!cmd:~1,-2!" == "!comspec!" ( echo *********** Autorun: %~f0 *********** echo !cmd!# endlocal ) ELSE if "!cmd:~,22!&qu...
by jeb
2023-Nov-06, 11:31 am
Forum: Windows CMD Shell
Topic: the auto exec page
Replies: 7
Views: 15528

Re: the auto exec page

There could be some info about the behavior of the autostart registry keys. It should be noted, that these are used not only when a new cmd window opens. Also for drag&drop actions to a batch file. It will also be called in FOR /F loops, this can have negative effects to batch files parsing the ...
by jeb
2023-Nov-06, 10:27 am
Forum: Windows CMD Shell
Topic: The page: echo.html
Replies: 3
Views: 4443

The page: echo.html

Hi Simon, the description on the echo.html can be improved. A more robust alternative is to separate with : instead of a space. ECHO:%_department% This might be more robust, but still not good :-) It fails for set "var=\..\..\..\..\windows\system32\calc.exe" echo:%var% The best and only sa...
by jeb
2023-Aug-23, 8:31 am
Forum: Windows CMD Shell
Topic: PUSHD example logic inverted
Replies: 3
Views: 9979

Re: PUSHD example logic inverted

You are right, just tested to be absolutely sure.
by jeb
2023-Aug-03, 1:11 pm
Forum: Windows CMD Shell
Topic: Local variables not cleaned-up on batch script crash
Replies: 1
Views: 9122

Re: Local variables not cleaned-up on batch script crash

Hi Jesus2099, the problem/feature of the missing endlocal on syntax errors is known, see Exit from nested batch file . It can be useful to examine all variables when a batch file crashes. But in your case, you want a clean environment after calling a batch file, even after a syntax error. I suppose,...
by jeb
2023-May-10, 2:17 pm
Forum: Windows CMD Shell
Topic: Function to Sanitize User Input
Replies: 2
Views: 4527

Re: Function to Sanitize User Input

Nice try, ... but try to get it working with this simple test string :o Set "_example=jeb1: Part1 ^ & Part2 !"^&" & Part3" To avoid the first problem when showing the _example variable, I changed the code a bit REM Replace: Echo Input: %_example% <nul set /p ".=Y...