Need some help in Batch file assigning variable value ?

People,

Can anyone here please assist me with the batch script below:

C:\WINDOWS\system32>bcdedit /store C:\WinPE_Combined\Media\Boot\BCD /enum | find "osdevice"
osdevice                ramdisk=[boot]\sources\boot.wim,{7619daa8-fafa-11d9-b411-000476eba66e}

Open in new window


I need to assign like this OSID={7619daa8-fafa-11d9-b411-000476eba66e}

Thanks in advance.
LVL 9
Senior IT System EngineerIT ProfessionalAsked:
Who is Participating?
 
NVITCommented:
for /f "tokens=2 delims=," %%a in ('bcdedit /store C:\WinPE_Combined\Media\Boot\BCD /enum ^| find "osdevice"') do (
  set OSID=%%a
  echo OSID=%OSID%
)

Open in new window

1
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
THanks NVIT,

but somehow:

%%a was unexpected at this time.

Open in new window

0
 
NVITCommented:
Because it's supposed to be saved in a bat file.
If you run it on the the CMD line, change all the %% to %
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Thanks man !
yes it works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.