"Frank P. Westlake" <
frank.w...@gmail.net> wrote in message
news:jfmmbq$bcp$1...@news.albasani.net...
Well, I'm thoroughly confused now about quite what is under discussion.
at 1201240032, Sambul complained to Todd (paraphrased)
...in Win7 64-bit it can't calculate !line:~15,1! resulting in ~15,1 .
SETLOCAL ENABLEEXTENSIONS
...
for /f "tokens=* delims=" %%a in ('%%diskpart%% ^| find "Volume"') do
(
set line=%%a
if "!line:~15,1!" equ " " (
echo Mounting Volume %line:~9,3% Label: %line:~19,11%
set dsc=select$Svolume$S%line:~9,3%$_assign$_exit & %diskpart%
...
Fair enough - missing ENABLEDELAYEDEXPANSION so !substring! won't be
correctly evaluated.
at 1201240049,
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
...
for /f "tokens=* delims=" %%a in ('%%diskpart%% ^| find "Volume"') do
(
set line=%%a
if "!line:~15,1!" equ " " (
echo Mounting Volume %line:~9,3% Label: %line:~19,11%
set dsc=select$Svolume$S%line:~9,3%$_assign$_exit & %diskpart%
...
The complaint was unchanged, but the missing ENABLEDELAYEDEXPANSION had been
included.
Then at 1201240312,
Your code doesn't work: "Unbalanced Parentheses". But this one
apparently does: :)
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
...
for /f "tokens=* delims=" %%a in ('%%diskpart%% ^| findstr "Volume"') do
(
set line=%%a
if "!line:~15,1!" equ " " (
echo Mounting Volume !line:~9,3! Label: !line:~19,11!
set dsc=select$Svolume$S!line:~9,3!$_assign & %diskpart% >nul
...
So - FIND has become FINDSTR and "%" corrected to "!" in the ECHO and SET
lines.
Problem solved??
What do you mean by
> Call Echo select volume %%line:~9,3%%
>
> The variable 'line' did not expand using delayed expansion:
>
> Echo select volume !line:~9,3!
These two should yield identical results because ...%%line:~9,3%% would be
executed as
ECHO...%line:~9,3% in the context of the CALL, hence LINE has the run-time
value assigned by the FOR.
Does it not do that for you? It does for me in both XP and W7/64. What are
these 'errors' you refer to in your final paragraph? Contaminated
environment as Todd suggests, perhaps?