after the claim of Jan Antonin, I take a closer look at the problem and I found a nearly simple method
Jan Antonin wrote:My biggest (not from the pragmatic point of view of course) contribution which I am really proud of will be an ultimate method of obtainig all command line arguments of a sript inside from the script of course. With no compromise, without any temp file. And storing these arguments inside a normal named variable like %myVar%, not %1.
I dont care about the speed (I care but there is no principal difference in a speed - the upper bound of time is polynomial depending on a lenght of an input )
Code: Select all
@echo off
setlocal EnableDelayedExpansion
for /F "tokens=3 delims=:" %%F in ("%~0") do goto %%F
:getParam
(set LF=^
%=empty=%
)
> nul break | (%~d0\:GetParams:\..\%~pnx0
REM %%LF%% )
REM ###,%*,# %%LF%%
)
for /F "delims=" %%L in ('doskey /macros ^|findstr /R "^return="') do (
set "cmdLine=%%L"
)
set "args=!cmdLine:*###,=!"
set "args=!args:""="!"
set "args=!args:$$=$!"
set "args=!args:~0,-10!"
doskey return=
echo args: --- !args! ---
exit /b
:GetParams
rem echo !cmdcmdline!
set "line=!cmdcmdline!"
set "line=!line:"=""!"
set "line=!line:$=$$!"
doskey return=!line!
exit
Former I was aware that you can access the arguments there, but I wasn't able to return the values back to the parent process.
First I played a bit with splitting the cmdcmline into single chars and tranfser each char via the exitcode, but it's slow and it has the disadvantage that each character has to be identified and converted to the ASCII value.
Then I remembered the doskey technic to return values from a child process, that's all.
Many thanks to Jan Antonin, without you I would have already give up
I'm still eager awaiting your solution
jeb