M
Mark V
multi-line command output to single Var?
(From CMD and not a batch) W2K
Through some SET tricks is it possible to capture a command's
STDOUT (multiple lines) using a one-liner FOR, appending each line
to a single variable?
I do not want to use an intermediate file, and this would have to
run as
CMD.EXE /c FOR ...
Example:
C:\temp4>subst
X:\: => D:\temp
Y:\: => C:\temp4
Z:\: => C:\temp6
C:\temp4>for /f "Tokens=1 Delims=:" %a in ('subst.exe') do echo/ %a
C:\temp4>echo/ X
X
C:\temp4>echo/ Y
Y
C:\temp4>echo/ Z
Z
Wanted:
SET ANS
ANS=XYZ
(or with delimiters if necessary,
ANS=$X$Y$Z )
ALTERNATIVE:
As above but all data on one single STDOUTline
Background: Trying to find a workaround from inside AutoIt3
for the apparent limitation of StdOutRead() only reading a single
output line. (rather noob w AU3 BTW)
And I do not want to write to disk at all.
Ultimate goal is to recover SUBST output into AU3. (sans file)
Or any other means of IDing Substituted drives on a system
from AU3.
Any insight would be appreciated.
PS Autoscript fora are Down at this time.
(From CMD and not a batch) W2K
Through some SET tricks is it possible to capture a command's
STDOUT (multiple lines) using a one-liner FOR, appending each line
to a single variable?
I do not want to use an intermediate file, and this would have to
run as
CMD.EXE /c FOR ...
Example:
C:\temp4>subst
X:\: => D:\temp
Y:\: => C:\temp4
Z:\: => C:\temp6
C:\temp4>for /f "Tokens=1 Delims=:" %a in ('subst.exe') do echo/ %a
C:\temp4>echo/ X
X
C:\temp4>echo/ Y
Y
C:\temp4>echo/ Z
Z
Wanted:
SET ANS
ANS=XYZ
(or with delimiters if necessary,
ANS=$X$Y$Z )
ALTERNATIVE:
As above but all data on one single STDOUTline
Background: Trying to find a workaround from inside AutoIt3
for the apparent limitation of StdOutRead() only reading a single
output line. (rather noob w AU3 BTW)
And I do not want to write to disk at all.
Ultimate goal is to recover SUBST output into AU3. (sans file)
Or any other means of IDing Substituted drives on a system
from AU3.
Any insight would be appreciated.
PS Autoscript fora are Down at this time.