Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Set Variable in nested FOR /F Loop

$
0
0

Hi there

at the moment I have an Problem I cant´t understand....

I have to change the BCD store and add some entries. So I made first an text file with the partitions/installation to add.

This looks so:

E:\imageinfo\Windows 8.1 - Testimage V1.06
F:\imageinfo\Windows 10 - Testimage V1.03

From here I extract the drive letter (%part%) and the name (%desc%)

Next step would be to create the entry via bcdedit. This gives me an guid which i need to alter the settings.

But this doesn´t work.

I use this code:

setlocal enabledelayedexpansion

for /f "tokens=1,4 delims=\ " %%i in ('type names.ttt') do (
set part=%%i
set desc=Windows_%%j
bcdedit /store %bootstore% /create /d "%desc%" /application osloader > guid.ttt
for /f "tokens=3 delims= " %%c in ('type guid.ttt') do set guid=%%c
sleep 1
bcdedit /store %bootstore% /set %guid% device partition=%part% >nul
bcdedit /store %bootstore% /set %guid% osdevice partition=%part% >nul
bcdedit /store %bootstore% /set %guid% path \Windows\system32\winload.efi >nul
bcdedit /store %bootstore% /set %guid% systemroot \Windows >nul
bcdedit /store %bootstore% /set %guid% bootmenupolicy Standard >nul
bcdedit /store %bootstore% /set %guid% detecthal Yes >nul

)

The variable %guid% is always empty - no matter what I try.

The command looks in the command windows like this

bcdedit /store c:\boot\BCD_TEST set   device partition=J:

Between set and device are three blanks - but it should be the %guid%

Where´s my fault? Doesn´t it work in an loop? It should.

One more thing - the part 

bcdedit /store %bootstore% /create /d "%desc%" /application osloader > guid.ttt
for /f "tokens=3 delims= " %%c in ('type guid.ttt') do set guid=%%c

is working outside the loop as it should.

It seems that %guid% is set right after the ) - but why and how to get thisinside the brackets?

Thank you!



Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>