• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 112
  • Last Modified:

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.
0
Senior IT System Engineer
Asked:
Senior IT System Engineer
  • 2
  • 2
2 Solutions
 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now